File tree Expand file tree Collapse file tree 4 files changed +51
-7
lines changed
main/java/org/example/myapp/duplicate
test/java/org/example/myapp/duplicate
inject-generator/src/main/java/io/avaje/inject/generator Expand file tree Collapse file tree 4 files changed +51
-7
lines changed Original file line number Diff line number Diff line change
1
+ package org .example .myapp .duplicate ;
2
+
3
+ import jakarta .inject .Singleton ;
4
+
5
+ @ Singleton
6
+ public class SameType {
7
+ @ Singleton
8
+ public static class Inner {}
9
+ }
Original file line number Diff line number Diff line change
1
+ package org .example .myapp .duplicate .two ;
2
+
3
+ import jakarta .inject .Singleton ;
4
+
5
+ @ Singleton
6
+ public class SameType {
7
+ @ Singleton
8
+ public static class Inner {}
9
+ }
Original file line number Diff line number Diff line change
1
+ package org .example .myapp .duplicate ;
2
+
3
+ import io .avaje .inject .BeanScope ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ import static org .assertj .core .api .Assertions .assertThat ;
7
+
8
+
9
+ class SameTypeTest {
10
+
11
+ @ Test
12
+ void testDuplicateShortName () {
13
+ try (BeanScope testScope = BeanScope .builder ().build ()) {
14
+
15
+ var sameType = testScope .get (SameType .class );
16
+ var sameTypeInner = testScope .get (SameType .Inner .class );
17
+ var sameType2 = testScope .get (org .example .myapp .duplicate .two .SameType .class );
18
+ var sameType2Inner = testScope .get (org .example .myapp .duplicate .two .SameType .Inner .class );
19
+
20
+ assertThat (sameType ).isNotNull ();
21
+ assertThat (sameTypeInner ).isNotNull ();
22
+ assertThat (sameType2 ).isNotNull ();
23
+ assertThat (sameType2Inner ).isNotNull ();
24
+ }
25
+ }
26
+ }
Original file line number Diff line number Diff line change @@ -65,13 +65,13 @@ final class SimpleModuleWriter {
65
65
this .modulePackage = scopeInfo .modulePackage ();
66
66
this .shortName = scopeInfo .moduleShortName ();
67
67
this .fullName = scopeInfo .moduleFullName ();
68
- Set <String > seen = new HashSet <>();
69
- duplicateTypes =
70
- ordering .ordered ().stream ()
71
- .map (MetaData ::type )
72
- .filter (t -> !seen .add (ProcessorUtils .shortType (t )))
73
- .flatMap (t -> Stream .of (t , t + "$DI" ))
74
- .collect (toSet ());
68
+ final Set <String > seen = new HashSet <>();
69
+ this . duplicateTypes =
70
+ ordering .ordered ().stream ()
71
+ .map (MetaData ::type )
72
+ .filter (t -> !seen .add (ProcessorUtils .shortType (t )))
73
+ .flatMap (t -> Stream .of (t , t + "$DI" ))
74
+ .collect (toSet ());
75
75
}
76
76
77
77
void write (ScopeInfo .Type scopeType ) throws IOException {
You can’t perform that action at this time.
0 commit comments