-
Notifications
You must be signed in to change notification settings - Fork 229
Clarify how augmentations affect existing compile-time errors. #4545
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
Merged
+57
−1
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| Author: [email protected], [email protected], [email protected] | ||
|
|
||
| Version: 1.38 (see [Changelog](#Changelog) at end) | ||
| Version: 1.40 (see [Changelog](#Changelog) at end) | ||
|
|
||
| Experiment flag: augmentations | ||
|
|
||
|
|
@@ -1003,6 +1003,43 @@ the combined declaration.* | |
|
|
||
| [analyzer package]: https://pub.dev/packages/analyzer | ||
|
|
||
| ### Compile errors with augmentations | ||
|
|
||
| Many existing compile-time errors in the language specification are only | ||
| meaningful after semantic analysis so only make sense to check after | ||
| augmentations are applied. For example: | ||
|
|
||
| > Let `C` be a concrete class declared in library `L`, with interface `I`. | ||
| > Assume that `I` has a member signature `m` which is accessible to `L`. It is a | ||
| > compile-time error if `C` does not have a concrete member with the same name as | ||
| > `m` and accessible to `L`, ... | ||
|
|
||
| This error says that a non-abstract class must fully implement its interface. | ||
| We don't know what methods a class even has until semantic analysis lets us | ||
| see inherited methods, and that happens after augmentation. Thus this error is | ||
| checked after augmentations have been applied. Therefore, there is no error in: | ||
|
|
||
| ```dart | ||
| abstract class I { | ||
| m(); | ||
| } | ||
|
|
||
| class C implements I {} | ||
|
|
||
| augment class C { | ||
| m() {} | ||
| } | ||
| ``` | ||
|
|
||
| The general rule is that compile-time errors should be checked after | ||
| augmentations are applied when possible to do so. In other words, if the | ||
| library is well-formed enough that augmentations *can* be applied, then they | ||
| should be. And if doing so eliminates what would otherwise be a compile-time | ||
| error, then that error should not be reported. | ||
|
|
||
| Put another way, moving code out of an introductory declaration into an | ||
| augmentation of it should not cause new errors to appear. | ||
munificent marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Dynamic semantics | ||
|
|
||
| The application of augmentation declarations to an augmented declaration | ||
|
|
@@ -1216,6 +1253,11 @@ and assume the third point is always true. | |
|
|
||
| ## Changelog | ||
|
|
||
| ### 1.40 | ||
|
|
||
| * Clarify how applying augmentations interacts with compile-time errors | ||
| (#3690). | ||
|
|
||
| ### 1.39 | ||
|
|
||
| * Non-semantic copy editing. Remove some redundant specification. Clarify | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.