-
Notifications
You must be signed in to change notification settings - Fork 207
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
Specify private override errors #2283
base: main
Are you sure you want to change the base?
Conversation
Visit the preview URL for this PR (updated for commit 2d1bbeb): https://dart-specification--pr2283-specify-private-over-30v5vvvy.web.app (expires Mon, 18 Jul 2022 17:59:29 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 6941ecd630c4f067ff3d02708a45ae0f0a42b88a |
specification/dartLangSpec.tex
Outdated
the checker should warn about all unimplemented methods, | ||
but allow clients to instantiate it freely.% | ||
the checker should raise an error for all unimplemented methods, | ||
but clients should be allowed to instantiate it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this saying that there won't be an error reported at the instantiation point, only at the class declaration point?
If so, we don't usually say where errors are reported, we just say that "it is an error if ...." (here: "A non-
abstract class does not implement its own interface", or "A non-abstract class does not have a concrete member implementation for each member of its interface").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this says that when we have abstract class A{}
any occurrences of A()
will be flagged as an error, but it is not an error for A
to have members in its interface that aren't implemented (with a correctly overriding signature), and the latter is an error for class A {}
, but A()
is allowed.
This would be the fundamental reason why we don't just say that being abstract is a computed property: If the class implements all methods then it's concrete, otherwise it is abstract. I believe that reasoning is still valid.
I think the location in the code where the error is reported is implied: When the error arises because of an instance creation A()
then it will flag the location where that instance creation occurs.
I adjusted the wording a bit, I think it's more unambiguous now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review response.
Main remaining issue: Do we or do we not include commentary about topics where a compile-time error is defined in one location and mentioned in 9 other locations (because it's similar to some other compile-time error which is defined at each of those 9 other locations)?
specification/dartLangSpec.tex
Outdated
the checker should warn about all unimplemented methods, | ||
but allow clients to instantiate it freely.% | ||
the checker should raise an error for all unimplemented methods, | ||
but clients should be allowed to instantiate it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this says that when we have abstract class A{}
any occurrences of A()
will be flagged as an error, but it is not an error for A
to have members in its interface that aren't implemented (with a correctly overriding signature), and the latter is an error for class A {}
, but A()
is allowed.
This would be the fundamental reason why we don't just say that being abstract is a computed property: If the class implements all methods then it's concrete, otherwise it is abstract. I believe that reasoning is still valid.
I think the location in the code where the error is reported is implied: When the error arises because of an instance creation A()
then it will flag the location where that instance creation occurs.
I adjusted the wording a bit, I think it's more unambiguous now.
One more thing needs to be handled: We currently rely on mixins to give rise to an implicitly induced class. This class must contain a set of members which is based on the instance member declarations in the given mixin This is only possible when we rely on the magic ability of a language processing tool to create declarations whose name is a private name in another library. So we'd need to explain how this "magic" feature can exist, except that it is only available to the compiler (in general: some feature is not available to developers who write software, only to "the system" in some sense). We can't explain the semantics of mixin application without mentioning this feature. |
That comes back to our definition of mixin application - are we copying, or allowing the same member to occur in more than one library. (And then there's the |
July 11th: Added some extra |
Cf. #2263 (comment), this PR eliminates the notion of a 'combined interface' from the language specification and clarifies the specification of how to check override errors. The main point in doing that is that it specifies how incorrect overrides are detected and reported in the case where a class or a similar declaration in a library L gives rise to an error involving private members that aren't accessible to L.
The discussion about this change gave rise to the following summary of the rules.
I've added some remarks inline to indicate that we do in fact have these properties.
We already specify this requirement for methods, abstract as well as concrete in line 2724.
This PR moves that rule from the section 'Instance Methods' to the section 'Classes', because it is relevant to getters and setters as well (the rule was worded correctly, but it was basically misplaced).
This is already specified in line 4917.
This was not stated unambiguously. This PR changes
\ref{interfaceInheritanceAndOverriding}
such that it is explicitly defined to be a 'member signature conflict' if an interface brings together two member signatures such that no combined member signature can be computed, and the section about classes says that it is a compile-time error if the interface of the class has any of these member signature conflicts.This covers mixins as well, because of the phrase 'It is a compile-time error for the mixin declaration if the$M_S$ class declaration would cause a compile-time error' in the section about mixin declarations.
This is defined as the combined member signature of a name with respect to a library, and it is defined as mentioned here in
\ref{interfaceInheritanceAndOverriding}
.This is already covered by the section 'Fully Implementing an Interface'.
This is already covered here.