[analyzer] An explicitly instantiated top level function tearoff is parsed as an instance creation expression #47005
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
With the
constructor-tearoffs
experiment enabled, the following code is accepted by the CFE but rejected by the analyzer:(Note: this code is based on https://dart-review.googlesource.com/c/sdk/+/211420)
The error message (at the line
f2<X, X>.self();
) isThe name 'f2' isn't a class.
(creation_with_non_type
).It seems like the analyzer is treating
f2<X, X>.self()
as an instance creation expression (understandable, because it looks like one), but in fact it is an explicitly instantiated tearoff of the top level functionf2
, followed by an invocation of the extension getterself
, followed by an implicit invocation of the extension methodcall
. This should all be allowed provided that theconstructor-tearoffs
experiment is enabled.Note: this seems similar to #46721 (which is marked as fixed), but the thing being torn off is a top level function rather than a method.
The text was updated successfully, but these errors were encountered: