@@ -138,8 +138,8 @@ abstract private class GeneratedType extends Type, GeneratedElement {
138
138
this .stubComment ( ) + this .stubAttributes ( ) + stubAccessibility ( this ) +
139
139
this .stubAbstractModifier ( ) + this .stubStaticModifier ( ) + this .stubPartialModifier ( ) +
140
140
this .stubKeyword ( ) + " " + this .getUndecoratedName ( ) + stubGenericArguments ( this ) +
141
- stubBaseTypesString ( ) + stubTypeParametersConstraints ( this ) + "\n{\n" +
142
- stubMembers ( assembly ) + "}\n\n"
141
+ this . stubBaseTypesString ( ) + stubTypeParametersConstraints ( this ) + "\n{\n" +
142
+ this . stubPrivateConstructor ( ) + this . stubMembers ( assembly ) + "}\n\n"
143
143
or
144
144
result =
145
145
this .stubComment ( ) + this .stubAttributes ( ) + stubUnsafe ( this ) + stubAccessibility ( this ) +
@@ -183,6 +183,22 @@ abstract private class GeneratedType extends Type, GeneratedElement {
183
183
)
184
184
}
185
185
186
+ string stubPrivateConstructor ( ) {
187
+ if
188
+ this instanceof Interface or
189
+ this .isStatic ( ) or
190
+ this .isAbstract ( ) or
191
+ exists ( this .( ValueOrRefType ) .getAConstructor ( ) ) or
192
+ not exists ( this .getAnInterestingBaseType ( ) ) or
193
+ not exists ( this .getAnInterestingBaseType ( ) .getAConstructor ( ) ) or
194
+ this .getAnInterestingBaseType ( ) .getAConstructor ( ) .getNumberOfParameters ( ) = 0
195
+ then result = ""
196
+ else
197
+ result =
198
+ " private " + this .getUndecoratedName ( ) + "() : base(" +
199
+ stubDefaultArguments ( getBaseConstructor ( this ) , this ) + ")" + " => throw null;\n"
200
+ }
201
+
186
202
private GeneratedMember getAGeneratedMember ( ) { result .getDeclaringType ( ) = this }
187
203
188
204
final Type getAGeneratedType ( ) {
@@ -670,18 +686,15 @@ private string stubParameters(Parameterizable p) {
670
686
)
671
687
}
672
688
673
- private string stubDefaultArguments ( Constructor baseCtor ) {
674
- exists ( Constructor c |
675
- baseCtor = getBaseConstructor ( c .getDeclaringType ( ) ) and
676
- baseCtor .getNumberOfParameters ( ) > 0 and
677
- not c .isStatic ( ) and
678
- result =
679
- concat ( int i , Parameter param |
680
- param = baseCtor .getParameter ( i ) and not param .getType ( ) instanceof ArglistType
681
- |
682
- "default(" + stubClassName ( param .getType ( ) ) + ")" , ", " order by i
683
- )
684
- )
689
+ private string stubDefaultArguments ( Constructor baseCtor , ValueOrRefType callingType ) {
690
+ baseCtor = getBaseConstructor ( callingType ) and
691
+ baseCtor .getNumberOfParameters ( ) > 0 and
692
+ result =
693
+ concat ( int i , Parameter param |
694
+ param = baseCtor .getParameter ( i ) and not param .getType ( ) instanceof ArglistType
695
+ |
696
+ "default(" + stubClassName ( param .getType ( ) ) + ")" , ", " order by i
697
+ )
685
698
}
686
699
687
700
private string stubParameterModifiers ( Parameter p ) {
@@ -827,7 +840,7 @@ private string stubConstructorInitializer(Constructor c) {
827
840
baseCtor = getBaseConstructor ( c .getDeclaringType ( ) ) and
828
841
if baseCtor .getNumberOfParameters ( ) = 0 or c .isStatic ( )
829
842
then result = ""
830
- else result = " : base(" + stubDefaultArguments ( baseCtor ) + ")"
843
+ else result = " : base(" + stubDefaultArguments ( baseCtor , c . getDeclaringType ( ) ) + ")"
831
844
)
832
845
or
833
846
// abstract base class might not have a constructor
0 commit comments