@@ -1887,26 +1887,43 @@ private predicate checkQualifiedVisibility(
18871887 not i instanceof TypeParam
18881888}
18891889
1890+ pragma [ nomagic]
1891+ private predicate isImplSelfQualifiedPath (
1892+ ImplItemNode impl , PathExt qualifier , PathExt path , string name
1893+ ) {
1894+ qualifier = impl .getASelfPath ( ) and
1895+ qualifier = path .getQualifier ( ) and
1896+ name = path .getText ( )
1897+ }
1898+
1899+ private TypeAliasItemNode resolveSelfAssocType ( PathExt qualifier , PathExt path ) {
1900+ exists ( ImplItemNode impl , string name |
1901+ isImplSelfQualifiedPath ( impl , qualifier , path , name ) and
1902+ result = impl .getAssocItem ( name )
1903+ )
1904+ }
1905+
18901906/**
18911907 * Gets the item that `path` resolves to in `ns` when `qualifier` is the
18921908 * qualifier of `path` and `qualifier` resolves to `q`, if any.
18931909 */
18941910pragma [ nomagic]
18951911private ItemNode resolvePathCandQualified ( PathExt qualifier , ItemNode q , PathExt path , Namespace ns ) {
1912+ // Special case for `Self::AssocType`; this always refers to the associated
1913+ // type in the enclosing `impl` block, if available.
1914+ q = resolvePathCandQualifier ( qualifier , path , _) and
1915+ ns .isType ( ) and
1916+ result = resolveSelfAssocType ( qualifier , path )
1917+ or
1918+ (
1919+ not exists ( resolveSelfAssocType ( qualifier , path ) )
1920+ or
1921+ not ns .isType ( )
1922+ ) and
18961923 exists ( string name , SuccessorKind kind , UseOption useOpt |
18971924 q = resolvePathCandQualifier ( qualifier , path , name ) and
18981925 result = getASuccessor ( q , name , ns , kind , useOpt ) and
18991926 checkQualifiedVisibility ( path , result , kind , useOpt )
1900- |
1901- // Special case for `Self::AssocType`; this always refers to the associated
1902- // type in the enclosing `impl` block, if available.
1903- forall ( ImplItemNode impl , TypeAliasItemNode alias |
1904- qualifier = impl .getASelfPath ( ) and alias = result
1905- |
1906- alias = impl .getAnAssocItem ( )
1907- or
1908- not exists ( impl .getAssocItem ( name ) .( TypeAliasItemNode ) )
1909- )
19101927 )
19111928}
19121929
0 commit comments