-
Notifications
You must be signed in to change notification settings - Fork 228
Description
Dart currently identifies libraries by their import URI.
That causes troubles in some situations:
- Different case on Windows (Analyzer reports mismatched types on Windows due to drive letter casing sdk#28895)
- Starting programs using
dart lib/main.dart("Interpreting this as package URI" message is confusing sdk#37978)
I suggest that we loosen the language specification to the point where the compiler is in charge of detecting when two URIs represent the same library, and it is allowed to canonicalize the URI of the library prior to resolving imports.
If the compiler can recognize that the underlying file system is case insensitive, then it is free (and encouraged) to consider Foo.dart and foo.dart the same library. It might still want to give a warning/hint that the code won't work on case-sensitive platforms.
If someone runs or imports lib/main.dart, the compiler is free to rewrite that to package:currentPackage/main.dart. We already do that for entry points (see also dart-lang/sdk#37978), but it sometimes fails for direct imports from the bin/ directory or other cases.
In general, allow the compiler to recognize that two URIs are actually referring the same library file using any available information, not just what the language specification can predict.
It still have to be in some way predictable. Generally, if it's the same underlying file, then it should be the same library.