Skip to content

CFE fails to report error for import prefix hidden by class member (when used to name a type) #34498

@stereotype441

Description

@stereotype441

Consider the following code:

import 'dart:core';
import 'dart:core' as core;

class A {
  core.List get core => null; // (1)
}

Based on my reading of the spec, there should be a compile-time error at (1), because the declaration of the getter core inside of class A hides the import prefix declared at top level. So the type core.List should be invalid.

But the front end accepts this code without complaint, and considers the return type of the getter to be the type List from dart:core.

Note that the analyzer's handling of this case isn't correct either; it also accepts the code without complaint, but it consideres the return type of the getter to be dynamic.

Metadata

Metadata

Labels

P2A bug or feature request we're likely to work onfront-end-missing-errorlegacy-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

Relationships

None yet

Development

No branches or pull requests

Issue actions