isAssignableFromType throws null check error for Function types
The implementation null asserts DartType.element2:
https://github.com/dart-lang/source_gen/blob/0d4c54d2a299643ba2a783ef2e9fcf878305a62d/source_gen/lib/src/type_checker.dart#L170-L171
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
@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.