@@ -515,11 +515,12 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
515515 * Holds if inferring types at `a` might depend on the type at `apos`
516516 * having `baseMention` as a transitive base type mention.
517517 */
518- private predicate relevantAccess ( Access a , AccessPosition apos , TypeMention baseMention ) {
518+ private predicate relevantAccess ( Access a , AccessPosition apos , Type base ) {
519519 exists ( Declaration target , DeclarationPosition dpos |
520- a .getTarget ( ) = target and
520+ adjustedAccessType ( a , apos , target , _, _) and
521+ target .getDeclaredType ( _, _) instanceof TypeParameter and
521522 accessDeclarationPositionMatch ( apos , dpos ) and
522- declarationBaseType ( target , dpos , baseMention , _, _)
523+ declarationBaseType ( target , dpos , base , _, _)
523524 )
524525 }
525526
@@ -572,7 +573,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
572573 predicate hasBaseTypeMention (
573574 Access a , AccessPosition apos , TypeMention baseMention , TypePath path , Type t
574575 ) {
575- relevantAccess ( a , apos , baseMention ) and
576+ relevantAccess ( a , apos , resolveTypeMentionRoot ( baseMention ) ) and
576577 exists ( Type sub | sub = inferRootType ( a , apos ) |
577578 not t = sub .getATypeParameter ( ) and
578579 baseTypeMentionHasTypeAt ( sub , baseMention , path , t )
@@ -587,18 +588,30 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
587588 }
588589 }
589590
591+ /**
592+ * Holds if the type of `a` at `apos` has the base type `base`, and when
593+ * viewed as an element of that type has the type `t` at `path`.
594+ */
595+ pragma [ nomagic]
596+ private predicate accessBaseType (
597+ Access a , AccessPosition apos , Type base , TypePath path , Type t
598+ ) {
599+ exists ( TypeMention tm |
600+ AccessBaseType:: hasBaseTypeMention ( a , apos , tm , path , t ) and
601+ base = resolveTypeMentionRoot ( tm )
602+ )
603+ }
604+
590605 /**
591606 * Holds if the declared type at `decl` for `dpos` at the `path` is `tp`
592607 * and `path` starts with a type parameter of `base`.
593608 */
594609 pragma [ nomagic]
595610 private predicate declarationBaseType (
596- Declaration decl , DeclarationPosition dpos , TypeMention base , TypePath path ,
597- TypeParameter tp
611+ Declaration decl , DeclarationPosition dpos , Type base , TypePath path , TypeParameter tp
598612 ) {
599- base = getABaseTypeMention ( _) and
600613 tp = decl .getDeclaredType ( dpos , path ) and
601- path .isCons ( resolveTypeMentionRoot ( base ) .getATypeParameter ( ) , _)
614+ path .isCons ( base .getATypeParameter ( ) , _)
602615 }
603616
604617 /**
@@ -639,10 +652,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
639652 ) {
640653 not exists ( getTypeArgument ( a , target , tp , _) ) and
641654 target = a .getTarget ( ) and
642- exists (
643- AccessPosition apos , DeclarationPosition dpos , TypeMention base , TypePath pathToTypeParam
644- |
645- AccessBaseType:: hasBaseTypeMention ( a , apos , base , pathToTypeParam .append ( path ) , t ) and
655+ exists ( AccessPosition apos , DeclarationPosition dpos , Type base , TypePath pathToTypeParam |
656+ accessBaseType ( a , apos , base , pathToTypeParam .append ( path ) , t ) and
646657 declarationBaseType ( target , dpos , base , pathToTypeParam , tp ) and
647658 accessDeclarationPositionMatch ( apos , dpos )
648659 )
0 commit comments