Skip to content

Package imports and relative imports don't resolve to the same type anymore #33887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
enyo opened this issue Jul 17, 2018 · 1 comment
Closed

Comments

@enyo
Copy link

enyo commented Jul 17, 2018

Dart VM version: 2.0.0-dev.69.0 (Tue Jul 17 14:57:16 2018 +0200) on "macos_x64"
macOS mojave

When to different files include the same file, once with import "package:mylib/test.dart"; and once with import "test.dart"; the dart runtime doesn't recognise the classes to be identical anymore.

// lib/test.dart
class Foo {
}

// lib/a.dart
import 'test.dart';
Foo getFoo() => new Foo();

// lib/b.dart
import 'package:mylib/test.dart';
import 'a.dart';

main() {
  Foo foo = getFoo(); // This fails
}

Error:

Error: A value of type '#lib1::Foo' can't be assigned to a variable of type '#lib2::Foo'.
Try changing the type of the left hand side, or casting the right hand side to '#lib2::Foo'.
@zoechi
Copy link
Contributor

zoechi commented Jul 17, 2018

dup of #33076

@enyo enyo closed this as completed Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants