@@ -290,8 +290,11 @@ private Virtualizable getAccessibilityDeclaringVirtualizable(Virtualizable v) {
290290
291291private string stubAccessibility ( Member m ) {
292292 if
293- m .getDeclaringType ( ) instanceof Interface or
293+ m .getDeclaringType ( ) instanceof Interface
294+ or
294295 exists ( m .( Virtualizable ) .getExplicitlyImplementedInterface ( ) )
296+ or
297+ m instanceof Constructor and m .isStatic ( )
295298 then result = ""
296299 else
297300 if m .isPublic ( )
@@ -445,17 +448,17 @@ private string stubGenericMethodParams(Method m) {
445448}
446449
447450private string stubConstraints ( TypeParameterConstraints tpc , int i ) {
448- tpc .hasConstructorConstraint ( ) and result = "new()" and i = 2
451+ tpc .hasConstructorConstraint ( ) and result = "new()" and i = 4
449452 or
450453 tpc .hasUnmanagedTypeConstraint ( ) and result = "unmanaged" and i = 0
451454 or
452455 tpc .hasValueTypeConstraint ( ) and result = "struct" and i = 0
453456 or
454457 tpc .hasRefTypeConstraint ( ) and result = "class" and i = 0
455458 or
456- result = tpc .getATypeConstraint ( ) .( TypeParameter ) .getName ( ) and i = 1
459+ result = tpc .getATypeConstraint ( ) .( TypeParameter ) .getName ( ) and i = 3
457460 or
458- result = stubClassName ( tpc .getATypeConstraint ( ) .( Interface ) ) and i = 1
461+ result = stubClassName ( tpc .getATypeConstraint ( ) .( Interface ) ) and i = 2
459462 or
460463 result = stubClassName ( tpc .getATypeConstraint ( ) .( Class ) ) and i = 1
461464}
@@ -492,9 +495,7 @@ private string stubTypeParametersConstraints(Declaration d) {
492495}
493496
494497private string stubImplementation ( Virtualizable c ) {
495- if c .isAbstract ( ) or c .getDeclaringType ( ) instanceof Interface
496- then result = ""
497- else result = " => throw null"
498+ if c .isAbstract ( ) then result = "" else result = " => throw null"
498499}
499500
500501private predicate isKeyword ( string s ) {
@@ -716,7 +717,11 @@ private string stubMember(Member m) {
716717private Constructor getBaseConstructor ( ValueOrRefType type ) {
717718 result =
718719 min ( Constructor bc |
719- type .getBaseClass ( ) .getAMember ( ) = bc
720+ type .getBaseClass ( ) .getAMember ( ) = bc and
721+ // not the `static` constructor
722+ not bc .isStatic ( ) and
723+ // not a `private` constructor, unless it's `private protected`, or if the derived class is nested
724+ ( not bc .isPrivate ( ) or bc .isProtected ( ) or bc .getDeclaringType ( ) = type .getDeclaringType + ( ) )
720725 |
721726 bc order by bc .getNumberOfParameters ( ) , stubParameters ( bc )
722727 )
@@ -725,13 +730,15 @@ private Constructor getBaseConstructor(ValueOrRefType type) {
725730private string stubConstructorInitializer ( Constructor c ) {
726731 exists ( Constructor baseCtor |
727732 baseCtor = getBaseConstructor ( c .getDeclaringType ( ) ) and
728- if baseCtor .getNumberOfParameters ( ) = 0
733+ if baseCtor .getNumberOfParameters ( ) = 0 or c . isStatic ( )
729734 then result = ""
730735 else result = " : base(" + stubDefaultArguments ( baseCtor ) + ")"
731736 )
732737 or
733738 // abstract base class might not have a constructor
734- not exists ( Constructor baseCtor | c .getDeclaringType ( ) .getBaseClass ( ) .getAMember ( ) = baseCtor ) and
739+ not exists ( Constructor baseCtor |
740+ c .getDeclaringType ( ) .getBaseClass ( ) .getAMember ( ) = baseCtor and not baseCtor .isStatic ( )
741+ ) and
735742 result = ""
736743}
737744
@@ -743,19 +750,13 @@ private string stubExplicit(ConversionOperator op) {
743750
744751private string stubGetter ( DeclarationWithGetSetAccessors p ) {
745752 if exists ( p .getGetter ( ) )
746- then
747- if p .isAbstract ( ) or p .getDeclaringType ( ) instanceof Interface
748- then result = "get; "
749- else result = "get => throw null; "
753+ then if p .isAbstract ( ) then result = "get; " else result = "get => throw null; "
750754 else result = ""
751755}
752756
753757private string stubSetter ( DeclarationWithGetSetAccessors p ) {
754758 if exists ( p .getSetter ( ) )
755- then
756- if p .isAbstract ( ) or p .getDeclaringType ( ) instanceof Interface
757- then result = "set; "
758- else result = "set => throw null; "
759+ then if p .isAbstract ( ) then result = "set; " else result = "set => throw null; "
759760 else result = ""
760761}
761762
0 commit comments