@@ -651,7 +651,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
651651 *
652652 * class Sub<T4> : Mid<C<T4>> { }
653653 *
654- * new Sub<int>().Method();
654+ * new Sub<int>().Method(); // Note: `Sub<int>` is a subtype of `Base<C<C<int>>>`
655655 * // ^^^^^^^^^^^^^^^^^^^^^^^ `a`
656656 * ```
657657 *
@@ -675,6 +675,11 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
675675 )
676676 }
677677
678+ /**
679+ * Holds if for `a` and corresponding `target`, the type parameter `tp` is
680+ * matched by a type argument at the access with type `t` and type path
681+ * `path`.
682+ */
678683 pragma [ nomagic]
679684 private predicate explicitTypeMatch (
680685 Access a , Declaration target , TypePath path , Type t , TypeParameter tp
@@ -687,17 +692,23 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
687692 private predicate implicitTypeMatch (
688693 Access a , Declaration target , TypePath path , Type t , TypeParameter tp
689694 ) {
695+ // We can get the type of `tp` from one of the access positions
690696 directTypeMatch ( a , target , path , t , tp )
691697 or
698+ // We can get the type of `tp` by going up the type hiearchy
692699 baseTypeMatch ( a , target , path , t , tp )
693700 }
694701
695702 pragma [ inline]
696703 private predicate typeMatch (
697704 Access a , Declaration target , TypePath path , Type t , TypeParameter tp
698705 ) {
706+ // A type given at the access corresponds directly to the type parameter
707+ // at the target.
699708 explicitTypeMatch ( a , target , path , t , tp )
700709 or
710+ // No explicit type argument, so we deduce the parameter from other
711+ // information
701712 implicitTypeMatch ( a , target , path , t , tp )
702713 }
703714
@@ -742,12 +753,14 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
742753 pragma [ nomagic]
743754 Type inferAccessType ( Access a , AccessPosition apos , TypePath path ) {
744755 exists ( DeclarationPosition dpos | accessDeclarationPositionMatch ( apos , dpos ) |
756+ // A suffix of `path` leads to a type parameter in the target
745757 exists ( Declaration target , TypePath prefix , TypeParameter tp , TypePath suffix |
746758 tp = target .getDeclaredType ( pragma [ only_bind_into ] ( dpos ) , prefix ) and
747759 path = prefix .append ( suffix ) and
748760 typeMatch ( a , target , suffix , result , tp )
749761 )
750762 or
763+ // `path` corresponds directly to a concrete type in the declaration
751764 exists ( Declaration target |
752765 result = target .getDeclaredType ( pragma [ only_bind_into ] ( dpos ) , path ) and
753766 target = a .getTarget ( ) and
0 commit comments