Skip to content

Constant evaluation doesn't record instantiation information for generic functions. #37608

@stereotype441

Description

@stereotype441

Consider the following code (adapted from https://github.com/dart-lang/sdk/blob/master/pkg/front_end/test/constants/data/function.dart):

T method1<T>(T t) => t;
const function0 = method1;
const int Function(int) instantiation0 = method1;

The analyzer computes the same constant value for both function0 and instantiation0. But in fact they are not the same constant. Type inference should determine that in order for method1 to match the declared type of int Function(int), the generic function method1 needs to be instantiated with the type parameter int, so the constant value of instantiation0 should reflect this.

Discovered while adapting the analyzer to use the CFE/dart2js "ID test" framework.
I'm currently working on a CL that demonstrates the bug.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp 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