-
Notifications
You must be signed in to change notification settings - Fork 213
[Class Modifiers] Overlap in lint and base/final subtyping restriction #2871
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
Comments
No, not entirely. The error case allows a The lint " Of these, only The 5x5x4 table of superclass, subclass, relation and its effect (within the same library) would be:
In general, the errors and lints are all about inheriting implementation.
These restrictions are strongly enforced outside of the library.
Abbreviated and reordered, that would be:
@eernstg Am I missing anything? |
[Edit Mar 2: Adjusted the terminology in the rule about implicitly induced class modifiers for a Big tables is hard work. ;-) I think the 'see supers' classification is a little bit non-obvious, and I'd still like to treat So we consider the
In particular, a Other than this, Here's your table again, simplified a little bit because we never mention
@lrhn, does that capture your intentions around 'see supers'? |
I think so. Let me try my own words:
Not sure it's the same thing. |
I think it's the same thing: The properties 'prevents implementation and prevents inheritance' are sufficient to ensure that we're in the first bullet in my rule; 'prevents implementations, but not inheritance' ensure that we are not in the first bullet, but we are indeed in the second bullet; and so on. Nice! This also serves as a double check on the sanity of the rules. |
I'd like to take another look at this and clarify my understanding with the specification. @eernstg @lrhn How does the base/final subtype restriction come into play with induced modifiers? It seems like any class/mixin with a supertype that is base or final would be induced either base or final. Does this example induce any modifiers? From the two comments above, I'm a little confused on what happens here.
Same with this example:
Could you help me clarify how the |
The implicitly induced modifiers are just as good as the explicitly written ones. I'd prefer to say that we have a program with modifiers This means that we apply a very simple local check, which is possible because we have changed the program such that it has
Yes. The implicitly induced modifiers should be exactly sufficient to avoid the error and the lint (where base class A {}
sealed /*base*/ class B extends A {}
final class C {}
sealed /*base*/ mixin M implements C {} The reason why we must implicitly induce We do not induce
The implicitly induced But there is no need to make them an exception, they just happen to be non-re-opening by construction, they can be checked according to the standard rules (actually, that's the whole point ;-). |
There's a lot in these comments. :) Is this all sorted out now, or is there more to do here? |
Lint and error are now completed, we can close this out now. |
In the spec, it mentions in the "Disallowing implementation" section:
It is a compile-time error if a subtype of a declaration marked base or final is not marked base, final, or sealed. This restriction applies to both direct and indirect subtypes and along all paths that introduce subtypes: implements clauses, extends clauses, with clauses, and on clauses. This restriction applies even to types within the same library.
Then in the "reopen lint" section it states:
Extends or mixes in a class, mixin, or mixin class marked interface or final and is not itself marked interface or final.
Doesn't the error cover the
final
case in the lint already?Is the lint supposed to only cover
interface
types? And if so, do we want a lint or annotation at all for just this one scenario?cc @pq @bwilkerson @dart-lang/language-team
The text was updated successfully, but these errors were encountered: