@@ -1467,10 +1467,6 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
14671467 private predicate typeMatch (
14681468 Access a , AccessEnvironment e , Declaration target , TypePath path , Type t , TypeParameter tp
14691469 ) {
1470- // A type given at the access corresponds directly to the type parameter
1471- // at the target.
1472- explicitTypeMatch ( a , e , target , path , t , tp )
1473- or
14741470 // We can infer the type of `tp` from one of the access positions
14751471 directTypeMatch ( a , e , target , path , t , tp )
14761472 or
@@ -1481,6 +1477,44 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
14811477 typeConstraintBaseTypeMatch ( a , e , target , path , t , tp )
14821478 }
14831479
1480+ /**
1481+ * Gets the type of `a` and `apos` at `path` using declared type
1482+ * information at the access or declaration, if any.
1483+ */
1484+ pragma [ nomagic]
1485+ Type getAccessDeclaredType ( Access a , AccessEnvironment e , AccessPosition apos , TypePath path ) {
1486+ exists ( DeclarationPosition dpos , Declaration target |
1487+ accessDeclarationPositionMatch ( apos , dpos )
1488+ |
1489+ result = target .getDeclaredType ( dpos , path ) and
1490+ target = a .getTarget ( e ) and
1491+ not result instanceof TypeParameter
1492+ or
1493+ exists ( TypePath prefix , TypeParameter tp , TypePath suffix |
1494+ tp = target .getDeclaredType ( dpos , prefix ) and
1495+ path = prefix .append ( suffix ) and
1496+ explicitTypeMatch ( a , e , target , suffix , result , tp )
1497+ )
1498+ )
1499+ }
1500+
1501+ /**
1502+ * Gets the inferred type of `a` and `apos` at `path` using inferred type
1503+ * information which is not explicitly declared, if any.
1504+ */
1505+ pragma [ nomagic]
1506+ Type getAccessInferredType ( Access a , AccessEnvironment e , AccessPosition apos , TypePath path ) {
1507+ exists (
1508+ DeclarationPosition dpos , Declaration target , TypePath prefix , TypeParameter tp ,
1509+ TypePath suffix
1510+ |
1511+ accessDeclarationPositionMatch ( apos , dpos ) and
1512+ tp = target .getDeclaredType ( dpos , prefix ) and
1513+ path = prefix .append ( suffix ) and
1514+ typeMatch ( a , e , target , suffix , result , tp )
1515+ )
1516+ }
1517+
14841518 /**
14851519 * Gets the inferred type of `a` at `path` for position `apos` and environment `e`.
14861520 *
@@ -1521,21 +1555,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
15211555 */
15221556 pragma [ nomagic]
15231557 Type inferAccessType ( Access a , AccessEnvironment e , AccessPosition apos , TypePath path ) {
1524- exists ( DeclarationPosition dpos | accessDeclarationPositionMatch ( apos , dpos ) |
1525- // A suffix of `path` leads to a type parameter in the target
1526- exists ( Declaration target , TypePath prefix , TypeParameter tp , TypePath suffix |
1527- tp = target .getDeclaredType ( dpos , prefix ) and
1528- path = prefix .append ( suffix ) and
1529- typeMatch ( a , e , target , suffix , result , tp )
1530- )
1531- or
1532- // `path` corresponds directly to a concrete type in the declaration
1533- exists ( Declaration target |
1534- result = target .getDeclaredType ( dpos , path ) and
1535- target = a .getTarget ( e ) and
1536- not result instanceof TypeParameter
1537- )
1538- )
1558+ result = [ getAccessDeclaredType ( a , e , apos , path ) , getAccessInferredType ( a , e , apos , path ) ]
15391559 }
15401560 }
15411561
@@ -1677,6 +1697,14 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
16771697
16781698 import M
16791699
1700+ Type getAccessDeclaredType ( Input:: Access a , Input:: AccessPosition apos , TypePath path ) {
1701+ result = M:: getAccessDeclaredType ( a , _, apos , path )
1702+ }
1703+
1704+ Type getAccessInferredType ( Input:: Access a , Input:: AccessPosition apos , TypePath path ) {
1705+ result = M:: getAccessInferredType ( a , _, apos , path )
1706+ }
1707+
16801708 Type inferAccessType ( Input:: Access a , Input:: AccessPosition apos , TypePath path ) {
16811709 result = M:: inferAccessType ( a , _, apos , path )
16821710 }
0 commit comments