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

Update extension methods specification for prefix imports. #672

Merged
merged 3 commits into from
Nov 12, 2019

Conversation

lrhn
Copy link
Member

@lrhn lrhn commented Nov 7, 2019

Allow extensions imported with a prefix to be accessible for implicit invocation, but make them less specific than any extension imported without a prefix.

Allow extensions imported with a prefix to be accessible for implicit invocation, but make them less specific than any extension imported without a prefix.

Implicit extension member invocation can also apply to individual *cascade* invocations. A cascade is treated as if each cascade section was a separate member invocation on an expression with the same value as the cascade receiver expression (the expression before the first `..`). This means that a cascade like `o..foo()..bar()` may perform an implicit extension member invocation on `o` for `foo()` and a normal invocation on `o` for `bar()`. There is no way to specify the corresponding explicit member invocation without expanding the cascade to a sequence of individual member invocations.

##### Accessibility

An extension is *accessible* for an expression if it is declared in the current library, or if there is a non-deferred `import` declaration in the current library of a library with the extension in its export scope, where the name of the extension is not private and it is not hidden by a `hide` or `show` modifier of the import. _This includes (non-deferred) imports with a prefix._

It is a *compile-time error* if a deferred import declaration imports a library with an extension declaration in its export scope, unless all such extensions are hidden by `show` or `hide` modifiers on the deferred import. *This is a temporary restriction ensuring that no extensions are introduced using deferred imports, and it allows us to later introduce any semantics for such extensions without affecting existing code*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hide only. show is an error as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand, you mean that the extension is hidden by a show of something else. I found this confusing though. Consider re-phrasing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or will do, I actually updated the paragraph below instead.

3. *T<sub>1</sub>* is a subtype of of *T<sub>2</sub>* and either
4. not vice versa, or
5. the instantiate-to-bounds `on` type of `E1` is a subtype of the instantiate-to-bounds `on` type of `E2` and not vice versa.
1. The `E2` extension is only accessible from imports with a prefix and `E1` not, or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not current.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@lrhn lrhn merged commit 464cab6 into master Nov 12, 2019
@lrhn lrhn deleted the lrhn-sem-prefix branch March 12, 2020 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants