Skip to content

Analyzer summary type logic doesn't do downward type inference #32525

Closed
@stereotype441

Description

@stereotype441

Consider the following code:

T f<T>(T x) => x;
var x = [1].map(f);

The correct type to infer for x is Iterable<int>. As of 28cdeb3, the analyzer summary logic infers Iterable<dynamic>. The reason this happens is that the analyzer summary logic doesn't do downward inference at all; it only does upward inference. So the type of f in map(f) is assumed to be (dynamic) -> dynamic, and therefore the return type of the map call is inferred to be Iterable<dynamic>.

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failureslegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions