-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Is "Never" is an object at runtime? #52961
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
Unlike Typedefs of other types that do not have members behave like typedef RecordIntInt = (int, int);
typedef Void = void;
void main() {
print(Never.hashCode);
print((Never).hashCode);
print(Never.runtimeType);
//print(String.runtimeType); // compile-type error - semantic error.
print(RecordIntInt.runtimeType);
//print(void.runtimeType); // compile-time error - parse error.
print(Void.runtimeType);
} ➔
This behaviour, where what I can do with a typedef Handle = int; and typedef Handle = (int, int); without possibly breaking a client. |
We should actually have a compile-time error for
The error messages for |
Agree. There is no distinction between interface types and other types here, the only real difference is likely that the keyword A (I'm not sure we treat an instantiated type literal member access like |
Apparently, there's code in the wild that has expressions like @eernstg, should we initiate the breaking change process to forbid the access to members on type literals? |
Yes, I think it would be a good idea to treat it as a breaking change. I think the alternative (just make it a non-error) is too inconsistent to be helpful (exactly which type literals will allow this, and which ones won't?). Also, the fix is easy because the expression |
No idea if this is expected (i.e. in the spec) or not, but it definitely confused me on #52962:
Both analyzer and compilers seem to accept this as valid.
The text was updated successfully, but these errors were encountered: