Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify some points in Member Access design #3177

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/design/expressions/member_access.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- [Values](#values)
- [Facet binding](#facet-binding)
- [Compile-time bindings](#compile-time-bindings)
- [Lookup ambiguity](#lookup-ambiguity)
- [Lookup ambiguity](#lookup-ambiguity)
- [`impl` lookup](#impl-lookup)
- [`impl` lookup for simple member access](#impl-lookup-for-simple-member-access)
- [`impl` lookup for compound member access](#impl-lookup-for-compound-member-access)
Expand Down Expand Up @@ -254,10 +254,9 @@ fn PrintPointTwice() {

### Facet binding

If any of the above lookups would search for members of a
[facet binding](/docs/design/generics/terminology.md#facet-binding) `T:! C`, it
searches the facet `T as C` instead, treating the facet binding as an
[archetype](/docs/design/generics/terminology.md#archetype).
A search for members of a facet binding `T:! C` treats the facet binding as an
[archetype](/docs/design/generics/terminology.md#archetype), and finds members
of the facet `T` of facet type `C`.

For example:

Expand Down Expand Up @@ -301,7 +300,8 @@ interface Renderable {
fn Draw[self: Self]();
}
fn DrawChecked[T:! Renderable](c: T) {
// `Draw` resolves to `Renderable.Draw`.
// `Draw` resolves to `(T as Renderable).Draw` or
// `T.(Renderable.Draw)`.
c.Draw();
}

Expand Down Expand Up @@ -358,7 +358,7 @@ bindings that are in scope are unknown. Unlike for a template binding, the
actual value of a symbolic binding never affects the result of member
resolution.

##### Lookup ambiguity
#### Lookup ambiguity

Multiple lookups can be performed when resolving a member access expression with
a [template binding](#compile-time-bindings). We resolve this the same way as
Expand All @@ -378,8 +378,8 @@ interface Renderable {
}

fn DrawTemplate2[template T:! Renderable](c: T) {
// Member lookup finds `Renderable.Draw` and the `Draw`
// member of the actual deduced value of `T`, if any.
// Member lookup finds `(T as Renderable).Draw` and the
// `Draw` member of the actual deduced value of `T`, if any.
c.Draw();
}

Expand Down
Loading