@@ -23,7 +23,8 @@ abstract private class GeneratedType extends RefType {
23
23
private string stubKeyword ( ) {
24
24
this instanceof Interface and result = "interface"
25
25
or
26
- this instanceof Class and ( if this instanceof EnumType then result = "enum" else result = "class" )
26
+ this instanceof Class and
27
+ ( if this instanceof EnumType then result = "enum" else result = "class" )
27
28
}
28
29
29
30
private string stubAbstractModifier ( ) {
@@ -50,6 +51,7 @@ abstract private class GeneratedType extends RefType {
50
51
result = this .getASupertype ( ) and
51
52
not result instanceof TypeObject and
52
53
not this instanceof EnumType and
54
+ // generic types have their source declaation (the corresponding raw type) as a supertype of themselves
53
55
result .getSourceDeclaration ( ) != this
54
56
}
55
57
@@ -330,20 +332,20 @@ private string stubMember(Member m) {
330
332
then result = ""
331
333
else (
332
334
result =
333
- " " + stubModifiers ( m ) + stubGenericMethodParams ( m ) + stubTypeName ( m .( Method ) .getReturnType ( ) ) +
334
- " " + m .getName ( ) + "(" + stubParameters ( m ) + ")" + stubImplementation ( m ) + "\n"
335
+ " " + stubModifiers ( m ) + stubGenericMethodParams ( m ) +
336
+ stubTypeName ( m .( Method ) .getReturnType ( ) ) + " " + m .getName ( ) + "(" + stubParameters ( m ) + ")"
337
+ + stubImplementation ( m ) + "\n"
335
338
or
336
339
m instanceof Constructor and
337
340
result =
338
341
" " + stubModifiers ( m ) + m .getName ( ) + "(" + stubParameters ( m ) + ")" +
339
342
stubImplementation ( m ) + "\n"
340
343
or
341
- m instanceof Field and
342
344
result =
343
- " " + stubModifiers ( m ) + stubTypeName ( m .getType ( ) ) + " " + m .getName ( ) + " = " +
344
- stubDefaultValue ( m .getType ( ) ) + ";\n"
345
+ " " + stubModifiers ( m ) + stubTypeName ( m .( Field ) . getType ( ) ) + " " + m .getName ( ) + " = " +
346
+ stubDefaultValue ( m .( Field ) . getType ( ) ) + ";\n"
345
347
or
346
- result = indent ( m .( NestedType ) .( GeneratedType ) .getStub ( ) ) )
348
+ result = indent ( m .( NestedType ) .( GeneratedType ) .getStub ( ) )
347
349
)
348
350
}
349
351
@@ -357,6 +359,7 @@ private string stubFakeConstructor(RefType t) {
357
359
then result = ""
358
360
else
359
361
exists ( string mod |
362
+ // this won't conflict with any existing private constructors, since we don't generate stubs for any private members.
360
363
if t instanceof EnumType then mod = " private " else mod = " protected "
361
364
|
362
365
if hasNoArgConstructor ( t ) then result = "" else result = mod + t .getName ( ) + "() {}\n"
0 commit comments