Skip to content

Implement recursive top-level inference #46579

Closed
@scheglov

Description

@scheglov

Currently in the analyzer we do inference in two phases - first we resolve the initializer presuming all not yet inferred types of fields are dynamic. Then we get dependencies as elements referenced by the initializer, and infer in the topological order.

Type inference in the following code in the analyzer is done incorrectly.

class A {
  static final a = A.b.c;
  static final b = A();
  final c = a;
}

When we resolve the initializer of a, we see that it references b, but its type is presumed to be dynamic, so we don't know that it also references c. So, we miss the cycle a -> c -> a.

We should do something like CFE does, and perform recursive inference.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondart-model-analyzer-specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions