Skip to content

[cfe] Instantiated function tearoff does have Object methods #46887

Closed
@eernstg

Description

@eernstg

[Edit] We do have a rule here which says that a term like a<b, c>.toString() must be parsed as a constructor invocation when a<b, c> is a type literal, not as an instance method invocation on that type literal. But the specification does not explicitly address the case where a<b, c> is a generic function instantiation.

Old text (striking out the part which is currently not resolved, cf. dart-lang/language#1802):

Consider the test co19/LanguageFeatures/Constructor-tear-offs/ambiguities_A08_t02.dart.

In this test there is an expression a<b, c>.toString() where a is a generic function and b and c are types. The parser should parse a<b, c> as <primary><selector> where <selector> further derives <typeArguments>, because the next token is '.' (which is one of those tokens that force the preceding construct to be considered as a <typeArguments>). I believe this part works as it should.

However, that expression should then denote a toString() invocation on a function object that is obtained by explicit generic function instantiation, and there should not be any errors. The CFE reports a compile-time error Method not found.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onlegacy-area-front-endLegacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions