17503caa05
Before this CL: If a library (say lib.dart) imports a file (say part.dart) that's actually a part (of some other library (say main.dart)) an error is given, but the "fake library" shortly representing the part is still "linked" into the libraries dependency list. This means that the component returned from a compilation is different from the combination of libraries one can get to if walking all LibraryDependency's. This also means that if we serialize the component we can't load it back in (https://github.com/dart-lang/sdk/issues/46706). It furthermore means that we have two different entities with the same fileUri and importUri. This CL rewrites a such import of a part to instead be an import of the "parent", i.e. if a library lib.dart imports part.dart that's a part of main.dart an error is issued, and the import is rewritten to be an import of main.dart instead. The same thing happens to exports. This alleviates the problems (i.e. no crashing if trying to load the dill, no referenec to a otherwise non-existing library etc), and has the added benefit of probably being what the user wants: Anything defined in part.dart (that isn't private) is still in scope from lib.dart. Change-Id: I17aca9db4edbf25b23d3ef301cf65589eeeb1635 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213344 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>