Skip to content

Analyzer and CFE disagree on the resolution of import prefixes that alias local names #38373

Closed
@Markzipan

Description

@Markzipan

Snippet:
main.dart:

import 'import.dart' as thing;

class Foo {
  List<thing.Type> field;
  thing() {}
}

import.dart:

class Type {}

Passes in the analyzer but errors in the CFE with:

main.dart:4:8: Error: 'thing.Type' can't be used as a type because 'thing' doesn't refer to an import prefix.
  List<thing.Type> field;
       ^^^^^^^^^^

What's our convention here? Following the analyzer's convention and using 'this' to refer to the local name would be the least breaking.

Activity

eernstg

eernstg commented on Sep 13, 2019

@eernstg
Member

We do not have separate namespaces for separate kinds of declarations (labels are special, everything else goes into the same namespace). The declaration of field is an instance member, so it's in the instance scope, and hence thing in thing.Type resolves to the other instance member called thing.

So the CFE is right.

This issue is already reported for the analyzer in #32248, so I'll close this one as a duplicate. I've added a comment about this issue on #32248.

@Markzipan, about dev-compiler-kernel-blocker: I think the right way ahead would be to mark #32248 as a blocker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Markzipan@eernstg

        Issue actions

          Analyzer and CFE disagree on the resolution of import prefixes that alias local names · Issue #38373 · dart-lang/sdk