Skip to content

lint request: ambiguous imports which include an element from the Dart SDK #58326

@srawlins

Description

@srawlins

Analyzer has a diagnostic for when two imports provide an element of the same name:

// a.dart ////////////////////
class File {}

// b.dart ////////////////////
class File {}

// c.dart ////////////////////
import 'a.dart';
import 'b.dart';

main() {
  File(); // error: ambiguous_import
}

But this error does not appear when a dart: element is at play.

// a.dart ////////////////////
class File {}

// c.dart ////////////////////
import 'a.dart';
import 'dart:io';

main() {
  File(); // MISSING ERROR
}

Flutter is hitting this in a few places, like https://github.com/flutter/flutter/blob/master/packages/flutter_goldens/test/flutter_goldens_test.dart with "package:file/file.dart" and "dart:io". It does not cause runtime problems, but I think is still confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions