@@ -64,6 +64,13 @@ private module Input1 implements InputSig1<Location> {
6464 kind = 3 and
6565 tp0 = TUnknownTypeTypeParameter ( id1 ) and
6666 id2 = 0
67+ or
68+ kind = 4 and
69+ exists ( ClassLikeDeclaration c |
70+ tp0 = TParentTypeParameterType ( c ) and
71+ id1 = idOfTypeParameterAstNode ( c ) and
72+ id2 = 0
73+ )
6774 |
6875 tp0 order by kind , id1 , id2
6976 )
@@ -389,9 +396,6 @@ module Input3 implements InputSig3 {
389396 Unified:: Callable getCallable ( ) { result = c }
390397
391398 override TypeMention getDeclaringType ( ) {
392- result = c .( EnumConstructor ) .getEnum ( ) .getNameNode ( )
393- or
394- not c instanceof EnumConstructor and
395399 exists ( ClassLikeDeclaration cls |
396400 c = cls .getAMember ( ) and
397401 result = getClassLikeDeclarationTypeMention ( cls )
@@ -405,9 +409,9 @@ module Input3 implements InputSig3 {
405409 or
406410 result = c .( FunctionDeclaration ) .getNameNode ( )
407411 or
408- result = c .( EnumConstructor ) . getEnclosingClass ( ) .getNameNode ( )
412+ result = c .( EnumCaseConstructor ) . getEnumCaseClass ( ) .getNameNode ( )
409413 or
410- not c instanceof EnumConstructor and
414+ not c instanceof EnumCaseConstructor and
411415 result = c .( ConstructorDeclaration ) .getNameNode ( )
412416 }
413417
@@ -659,10 +663,20 @@ module Input3 implements InputSig3 {
659663 result = getQualifierTypeMention ( invocation )
660664 }
661665
662- private predicate constructionReceiver ( Invocation i , Callable constructor , Expr receiver ) {
663- constructor = i .getTargetImpl ( _) and
664- constructor .asCallable ( ) instanceof ConstructorDeclaration and
665- receiver = i .getArgument ( 0 )
666+ private predicate constructionReceiver (
667+ Invocation i , Callable constructor , Expr receiver , TypePath enumPrefixPath
668+ ) {
669+ exists ( ConstructorDeclaration cd |
670+ constructor = i .getTargetImpl ( _) and
671+ cd = constructor .asCallable ( ) and
672+ receiver = i .getArgument ( 0 )
673+ |
674+ enumPrefixPath =
675+ TypePath:: singleton ( TParentTypeParameterType ( cd .( EnumCaseConstructor ) .getEnumCaseClass ( ) ) )
676+ or
677+ not cd instanceof EnumCaseConstructor and
678+ enumPrefixPath .isEmpty ( )
679+ )
666680 }
667681
668682 /**
@@ -696,11 +710,15 @@ module Input3 implements InputSig3 {
696710 M3:: ContextualTyping:: ContextualReturnType< ContextualConstructorReturnTypeInput > ;
697711
698712 private predicate needsContextualTyping ( Invocation i , TypePath path ) {
699- exists ( Callable constructor , Expr receiver , ClassLikeDeclarationType receiverType |
700- constructionReceiver ( i , constructor , receiver ) and
701- receiverType = inferType ( receiver )
713+ exists (
714+ Callable constructor , Expr receiver , TypePath enumPrefixPath ,
715+ ClassLikeDeclarationType receiverType , TypePath path0
716+ |
717+ constructionReceiver ( i , constructor , receiver , enumPrefixPath ) and
718+ receiverType = inferType ( receiver ) and
719+ path = path0 .stripPrefix ( enumPrefixPath )
702720 |
703- ContextualConstructorReturnType:: needsContextualTyping ( i , path ) and
721+ ContextualConstructorReturnType:: needsContextualTyping ( i , path0 ) and
704722 receiverType = constructor .getDeclaringType ( ) .getType ( )
705723 or
706724 // inherited constructor
@@ -710,18 +728,18 @@ module Input3 implements InputSig3 {
710728 |
711729 declType = constructor .getDeclaringType ( ) .getType ( ) and
712730 BaseTypes:: rootTypesSatisfaction ( receiverType , declType , abs , _, constraint ) and
713- path = TypePath:: singleton ( tp )
731+ path0 = TypePath:: singleton ( tp )
714732 |
715733 // `A<T> : B<T>`
716- exists ( TypePath path0 |
717- BaseTypes:: conditionSatisfiesConstraintTypeAt ( abs , _, constraint , path0 , tp ) and
718- ContextualConstructorReturnType:: needsContextualTyping ( i , path0 )
734+ exists ( TypePath path1 |
735+ BaseTypes:: conditionSatisfiesConstraintTypeAt ( abs , _, constraint , path1 , tp ) and
736+ ContextualConstructorReturnType:: needsContextualTyping ( i , path1 )
719737 )
720738 or
721739 // `A<T> : B`
722740 tp = receiverType .getATypeParameter ( ) and
723741 not BaseTypes:: conditionSatisfiesConstraintTypeAt ( abs , _, constraint , _, tp ) and
724- not exists ( Type t | t = i .getTypeQualifier ( path ) and not t instanceof PseudoType )
742+ not exists ( Type t | t = i .getTypeQualifier ( path0 ) and not t instanceof PseudoType )
725743 )
726744 )
727745 }
@@ -734,8 +752,7 @@ module Input3 implements InputSig3 {
734752 * as well as calls receivers, `self.init(0)` or `super.init(0)`.
735753 */
736754 predicate step ( AstNode n1 , TypePath prefix1 , AstNode n2 , TypePath prefix2 ) {
737- constructionReceiver ( n2 , _, n1 ) and
738- prefix1 .isEmpty ( ) and
755+ constructionReceiver ( n2 , _, n1 , prefix1 ) and
739756 prefix2 .isEmpty ( )
740757 }
741758
0 commit comments