File tree Expand file tree Collapse file tree
main/java/org/mapstruct/ap/internal/model
test/java/org/mapstruct/ap/test/bugs/_2133 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -472,7 +472,10 @@ private void sortPropertyMappingsByDependencies() {
472472 }
473473
474474 private Type getReturnTypeToConstructFromSelectionParameters (SelectionParameters selectionParams ) {
475- if ( selectionParams != null && selectionParams .getResultType () != null ) {
475+ // resultType only applies to method that actually has @BeanMapping annotation, never to forged methods
476+ if ( !( method instanceof ForgedMethod )
477+ && selectionParams != null
478+ && selectionParams .getResultType () != null ) {
476479 return ctx .getTypeFactory ().getType ( selectionParams .getResultType () );
477480 }
478481 return null ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MapStruct Authors.
3+ *
4+ * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+ */
6+ package org .mapstruct .ap .test .bugs ._2133 ;
7+
8+ import org .mapstruct .BeanMapping ;
9+ import org .mapstruct .Mapper ;
10+ import org .mapstruct .factory .Mappers ;
11+
12+ @ Mapper
13+ public interface Issue2133Mapper {
14+
15+ Issue2133Mapper INSTANCE = Mappers .getMapper ( Issue2133Mapper .class );
16+
17+ @ BeanMapping (resultType = Target .class )
18+ AbstractTarget map (Source source );
19+
20+ class Source {
21+
22+ private EmbeddedDto embedded ;
23+
24+ public EmbeddedDto getEmbedded () {
25+ return embedded ;
26+ }
27+
28+ public void setEmbedded (EmbeddedDto embedded ) {
29+ this .embedded = embedded ;
30+ }
31+ }
32+
33+ class Target extends AbstractTarget {
34+ }
35+
36+ abstract class AbstractTarget {
37+
38+ private EmbeddedEntity embedded ;
39+
40+ public EmbeddedEntity getEmbedded () {
41+ return embedded ;
42+ }
43+
44+ public void setEmbedded (EmbeddedEntity embedded ) {
45+ this .embedded = embedded ;
46+ }
47+ }
48+
49+ class EmbeddedDto {
50+
51+ private String s1 ;
52+
53+ public String getS1 () {
54+ return s1 ;
55+ }
56+
57+ public void setS1 (String s1 ) {
58+ this .s1 = s1 ;
59+ }
60+ }
61+
62+ class EmbeddedEntity {
63+
64+ private String s1 ;
65+
66+ public String getS1 () {
67+ return s1 ;
68+ }
69+
70+ public void setS1 (String s1 ) {
71+ this .s1 = s1 ;
72+ }
73+
74+ }
75+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MapStruct Authors.
3+ *
4+ * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+ */
6+ package org .mapstruct .ap .test .bugs ._2133 ;
7+
8+ import org .junit .Test ;
9+ import org .junit .runner .RunWith ;
10+ import org .mapstruct .ap .testutil .IssueKey ;
11+ import org .mapstruct .ap .testutil .WithClasses ;
12+ import org .mapstruct .ap .testutil .runner .AnnotationProcessorTestRunner ;
13+
14+ @ IssueKey ("2133" )
15+ @ WithClasses ( Issue2133Mapper .class )
16+ @ RunWith (AnnotationProcessorTestRunner .class )
17+ public class Issue2133Test {
18+
19+ @ Test
20+ public void shouldCompile () {
21+ }
22+
23+ }
You can’t perform that action at this time.
0 commit comments