-
Notifications
You must be signed in to change notification settings - Fork 108
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
isAssignableFromType throws null check error for Function types #619
Comments
@grouma this has been the cause of several unique unhandled exceptions in the Angular compiler. |
cc @natebosch |
Making an implementation that works for structural types is not trivial. I think that these types also don't work in the angular compiler though - you can't inject a Function type right? Is there some safeguard you can move earlier in the compilation to prevent this? |
I understand that, but perhaps it would make sense to throw an explicit error instead of knowingly failing a null check. For now, I'm creating an extension method to wrap this method and throw such an error if the underlying type is a FunctionType. |
Yeah, I think we can throw some more informative errors, and perhaps even more eagerly in some cases. |
The implementation null asserts
DartType.element2
:source_gen/source_gen/lib/src/type_checker.dart
Lines 170 to 171 in 0d4c54d
Which is always null for Function types:
https://github.com/dart-lang/sdk/blob/d6ff1193c5eb1d4b98e232f545cce49c63492b5c/pkg/analyzer/lib/src/dart/element/type.dart#L95-L96
The text was updated successfully, but these errors were encountered: