@@ -1361,6 +1361,14 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
13611361 module MatchingWithEnvironment< MatchingWithEnvironmentInputSig Input> {
13621362 private import Input
13631363
1364+ pragma [ nomagic]
1365+ private TypeParameter getDeclTypeParameter ( Declaration decl , TypeArgumentPosition tapos ) {
1366+ exists ( TypeParameterPosition tppos |
1367+ result = decl .getTypeParameter ( tppos ) and
1368+ typeArgumentParameterPositionMatch ( tapos , tppos )
1369+ )
1370+ }
1371+
13641372 /**
13651373 * Gets the type of the type argument at `path` in `a` that corresponds to
13661374 * the type parameter `tp` in `target`, if any.
@@ -1372,10 +1380,9 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
13721380 bindingset [ a, target]
13731381 pragma [ inline_late]
13741382 private Type getTypeArgument ( Access a , Declaration target , TypeParameter tp , TypePath path ) {
1375- exists ( TypeArgumentPosition tapos , TypeParameterPosition tppos |
1383+ exists ( TypeArgumentPosition tapos |
13761384 result = a .getTypeArgument ( tapos , path ) and
1377- tp = target .getTypeParameter ( tppos ) and
1378- typeArgumentParameterPositionMatch ( tapos , tppos ) and
1385+ tp = getDeclTypeParameter ( target , tapos ) and
13791386 not result instanceof UnknownType //and path.isEmpty())
13801387 )
13811388 }
@@ -2403,6 +2410,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
24032410 private predicate infersCertainTypeAt ( AstNode n , TypePath prefix , TypeParameter tp ) {
24042411 exists ( TypePath path |
24052412 hasInferredCertainType ( n , path ) and
2413+ not path .isEmpty ( ) and // implied by `isSnoc` below, but improves performance slightly
24062414 path .isSnoc ( prefix , tp )
24072415 )
24082416 }
@@ -2521,26 +2529,26 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
25212529 not Certain:: certainTypeConflict ( n , prefix , path , result )
25222530 )
25232531 or
2524- hasUnknownCertainTypeAt ( n , path ) and
2525- result instanceof UnknownType
2526- or
2527- infersTypeAt ( n , path , result .getATypeParameter ( ) )
2528- }
2529-
2530- private predicate hasUnknownCertainTypeAt ( AstNode n , TypePath path ) {
2532+ // If `n` has an explicitly unknown type at `prefix` and at the same time a certain
2533+ // type at `prefix.suffix`, then extend the unknown type information to any path
2534+ // extending `prefix.suffix` where there is no certain type information
25312535 exists ( TypePath prefix , TypePath suffix , Type certain , TypeParameter tp |
25322536 inferType0 ( n , prefix ) instanceof UnknownType and
25332537 certain = inferTypeCertain ( n , prefix .appendInverse ( suffix ) ) and
25342538 tp = certain .getATypeParameter ( ) and
25352539 path = prefix .append ( suffix ) .append ( TypePath:: singleton ( tp ) ) and
2536- not exists ( inferTypeCertain ( n , path ) )
2540+ not exists ( inferTypeCertain ( n , path ) ) and
2541+ result instanceof UnknownType
25372542 )
2543+ or
2544+ infersTypeAt ( n , path , result .getATypeParameter ( ) )
25382545 }
25392546
25402547 pragma [ nomagic]
25412548 private predicate infersTypeAt ( AstNode n , TypePath prefix , TypeParameter tp ) {
25422549 exists ( TypePath path |
25432550 exists ( inferType ( n , path ) ) and
2551+ not path .isEmpty ( ) and // implied by `isSnoc` below, but improves performance slightly
25442552 path .isSnoc ( prefix , tp )
25452553 )
25462554 }
0 commit comments