Skip to content

Dart analyzer interprets type hierarchy differently depending on symlink file structure #27828

Open
@ajrcarey

Description

@ajrcarey

Not sure if you folks like to receive issues submitted against dev sdk builds, but here we go...

SDK 1.21.0-dev.6.0 running on Ubuntu 16.10

Strong mode on

Consider the following type hierarchy:

abstract class A {

  void doA();

}

abstract class B<T> implements A {

  @override void doA();

  void alsoDoB();

}

class C {

  void doATypeThings(A a) {
    a.doA();
  }

}

class D implements B<D> {

  @override void doA() {}

  @override void alsoDoB() {}

}

class E {

  final D d;

  E(this.d);

}

class F {

  static final E _e = new E(new D());

  void doAllTheThings(C c) {
    c.doATypeThings(F._e.d); // <===== this is the line of interest
  }

}

Dart analyzer interprets this correctly and marks no errors. All good.

If I then move the definition of, e.g., class D out of this file and into another file that is then imported using an import 'package:...' statement, Dart analyzer reports the following error on the line marked with the comment above:

The argument type 'D' can't be assigned to the parameter type 'A'

I cannot escape the feeling that I am doing something wrong with my file structure that is causing this, but for the life of me I cannot see what. The error is not flagged when using SDKs 1.20.1 or 1.19.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-specIssues with the analyzer's implementation of the language spectype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions