Skip to content

import statement pathname can cause incorrect Type resolution #37245

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
speby opened this issue Jun 13, 2019 · 1 comment
Closed

import statement pathname can cause incorrect Type resolution #37245

speby opened this issue Jun 13, 2019 · 1 comment
Labels
legacy-area-analyzer Use area-devexp instead. P4 type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@speby
Copy link

speby commented Jun 13, 2019

Using Dart version: 2.3.0-dev.0.5.flutter-a1668566e5 (Tue Apr 30 20:35:41 2019 +0200) on "macos_x64"

Attached .ZIP contains a tiny set of Dart files and a main() method to print stuff to the console. Basically, if you have 2 different Dart files reference a class and you add 2 slashes in the pathname in the import statement, it will throw off the ability to correctly type-check the class in the other file.

Notice the 2 slashes in the import statement below (this is what causes the issue):
bin/main.dart

// To test this, leave 2 slashes in the import statement below to see the type fail to recognize in the call to compareInstance.
// Change it to a single-slash and it will work as intended.
import 'some_classes//some_classes.dart';
import 'another_class.dart';

main(List<String> arguments) {
  MyClass my_cls = MyClass();
  AnotherClass another_cls = AnotherClass();

  another_cls.compareInstance(my_cls);

}

bin/another_class.dart

import 'some_classes/some_classes.dart';

class AnotherClass {
  void compareInstance(Object my_class) {
    if (my_class is MyClass) {
      print("Yes it is an instance of MyClass");
    } else {
      print("No it is not an instance of MyClass");
    }
  }
}

bin/some_classes/some_classes.dart

class MyClass {
  final String text = "Hi!";
}

I am not certain but this may be related to this issue.

classname_clash.zip

@mit-mit mit-mit added the legacy-area-analyzer Use area-devexp instead. label Jun 19, 2019
@srawlins srawlins added the P4 label Jan 12, 2021
@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Nov 16, 2021
@srawlins
Copy link
Member

srawlins commented May 1, 2023

Duplicate of #36337

@srawlins srawlins marked this as a duplicate of #36337 May 1, 2023
@srawlins srawlins closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. P4 type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants