Skip to content

[analyzer] Wrong error is reported if an extension type declares an external variable #53335

@sgrekhov

Description

@sgrekhov

Analyzer reports an error if an extension type declares an external variable

extension type ET1(int id) {
  external int m; // COMPILE_TIME_ERROR.EXTENSION_TYPE_DECLARES_INSTANCE_FIELD. Extension types can't declare instance fields.
}

According to the spec external instance variables are allowed

A compile-time error occurs if the extension type declaration declares any instance variables, unless they are external.

An external instance variable is just a convenient notation for an external getter and (if not final) an external setter. They are allowed.

Tested on the edge (Aug 24, 2023) SDK on Linux x64

Metadata

Metadata

Assignees

Labels

P3A lower priority bug or feature requestdart-model-analyzer-specIssues with the analyzer's implementation of the language specdevexp-warningIssues with the analyzer's Warning codeslegacy-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