Support unqualified lookup into extended interfaces from classes and impls (#7217)

When a class extends an interface, referring to a member name of the
interface as an unqualified name should refer to the class's
corresponding associated entity value, not to the associated entity
itself. Similarly, in an `impl`, unqualified names of associated
entities should refer to the `impl`'s corresponding value for that
entity.

To support this, we treat `impl`s as `extend`ing their implemented facet
type, and we make lookups into an extended facet type use the `Self`
type of the extending `impl` or `class` if lookup finds an associated
entity. We already did the latter if the extending entity was an
interface; this extends the existing support for these other cases.
This commit is contained in:
Richard Smith
2026-05-19 18:01:54 +00:00
committed by GitHub
parent 0d7c4a99eb
commit ce080b3549
112 changed files with 962 additions and 4125 deletions
+8
View File
@@ -270,6 +270,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .F = %C.as.HasF.impl.F.decl
// CHECK:STDOUT: extend %HasF.ref
// CHECK:STDOUT: witness = %HasF.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -280,6 +281,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .G = %C.as.HasG.impl.G.decl
// CHECK:STDOUT: extend %HasG.ref
// CHECK:STDOUT: witness = %HasG.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -495,6 +497,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .A = %D.as.HasA1.impl.A.decl
// CHECK:STDOUT: extend %HasA1.ref
// CHECK:STDOUT: witness = %HasA1.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -505,6 +508,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .A = %D.as.HasA2.impl.A.decl
// CHECK:STDOUT: extend %HasA2.ref
// CHECK:STDOUT: witness = %HasA2.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -685,6 +689,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .I = %E.as.HasI.impl.I.decl
// CHECK:STDOUT: extend %HasI.ref
// CHECK:STDOUT: witness = %HasI.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -855,6 +860,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .K = %L.as.HasK.impl.K.decl
// CHECK:STDOUT: extend %HasK.ref
// CHECK:STDOUT: witness = %HasK.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1043,6 +1049,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .N = %O.as.HasN1.impl.N.decl
// CHECK:STDOUT: extend %HasN1.ref
// CHECK:STDOUT: witness = %HasN1.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1053,6 +1060,7 @@ fn P(o: O) {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .N = %O.as.HasN2.impl.N.decl
// CHECK:STDOUT: extend %HasN2.ref
// CHECK:STDOUT: witness = %HasN2.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT: