-
Notifications
You must be signed in to change notification settings - Fork 214
Can a constructor named runtimeType
or hashCode
be torn off?
#1718
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
For non-generic types, the answer is simply "yes", they can be torn off. Also, I think The current behavior for For And |
Thanks!
Then tests like
Perfect. The ambiguity I was worried about vanishes if |
Yes, that one should expect the compile-time error that |
@lrhn wrote:
I think the spec contains two examples of that syntax:
|
That's slightly different syntax. You can do the tear-off (which is what the parentheses ensure) then invoke the resulting generic function. Assume we have a generic
In general, you can only put |
Oops, my mistake is obvious, haha. Thanks for the great explanation, @lrhn ! |
This can probably be closed, I think it's all well-defined. My one caveat would be extension methods. I sort of want an explicit note (or test case) that the following results in an error: class C<T> {}
extension on Type {
int get ex => 1;
}
var a = C<int>.ex; But I can read that as "currently covered" in the "Constructor/type object member ambiguity" section. |
Uh oh!
There was an error while loading. Please reload this page.
Forgive my bare understanding of the parsing rules, but I was surprised to see co19 language tests like named_constructor_A03_t02 which include code like:
I had thought that
C<dynamic>
when not followed immediately by a.
would be a Type, which does not have a getter calledconstr
. In any case, assuming this is a valid test, I wonder then, given a class with constructorsruntimeType
orhashCode
, are the following variables constructor tearoffs or field accesses onType
?In other words, do constructors shadow instance getters that exist on
Type
, or vice versa?I think the question can extend to a constructor named
toString
.(C).toString
normally represents the tearoff of thetoString
function onType
, but what ifC
has a constructor namedtoString
?The text was updated successfully, but these errors were encountered: