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
@@ -111,6 +111,7 @@ fn F() {
// CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: extend %I.ref
// CHECK:STDOUT: witness = <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -162,6 +163,7 @@ fn F() {
// CHECK:STDOUT: %J.impl_witness: <witness> = impl_witness %J.impl_witness_table [concrete = constants.%J.impl_witness]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: extend %J.ref
// CHECK:STDOUT: witness = <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -268,6 +270,7 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Zero = %<error>.as.Z.impl.Zero.decl
// CHECK:STDOUT: extend %Z.ref
// CHECK:STDOUT: witness = <error>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -279,6 +282,7 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Zero = %Point.as.Z.impl.Zero.decl
// CHECK:STDOUT: extend %Z.ref
// CHECK:STDOUT: witness = %Z.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT: