Analyzer erroneously performs .call
tearoff on expressions whose type is a nullable type variable
#55734
Labels
analyzer-spec
Issues with the analyzer's implementation of the language spec
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
P2
A bug or feature request we're likely to work on
I'm currently trying to write up a specification for type inference within function bodies and initializer expressions, and this includes specifying when implicit
.call
tearoff should occur. I've discovered a difference in behavior between the analyzer and CFE.The following code is accepted by the analyzer but rejected by the CFE:
The analyzer accepts the code because, when considering whether to apply implicit
.call
tearoff to the expressiont
, it sees that the static type oft
isT?
, which is a type parameter type (with a?
suffix). It ignores the suffix and replaces the type parameter type with its bound,C
. Then it sees thatC
contains a.call
method with an appropriate type, so it inserts an implicit tearoff of.call
. This is not sound, however, becauset
might benull
.The CFE correctly gives an error for this code.
I'll work on a fix.
The text was updated successfully, but these errors were encountered: