dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

Create an implementation of MultiplyDefinedElement2 #57041

Closed DanTup closed 2 weeks ago

DanTup commented 2 weeks ago

Currently the class MultiplyDefinedElement2 doesn't appear to be implemented in the new element model. This makes it difficult to migrate code like that in https://dart-review.googlesource.com/c/sdk/+/387387 that inspects the conflictingElements.

Making MultiplyDefinedElementImpl implements MultiplyDefinedElement2 requires an implementation of Fragment firstFragment and List<Element2> conflictingElements2.

@bwilkerson @scheglov it turns out, there is a MultiplyDefinedFragment class already defined in element2.dart, though it also has no implementations. I feel like this might be the right way to solve this, though I'm not sure what the implementation of MultiplyDefinedFragment looks like (for ex. does it have a conflictingFragments? what are nextFragment and previousFragment?).

For the case I'm migrating for now I'm going to drop this, but since there's other code using MultiplyDefinedElement this probably needs solving before the migration is complete.

scheglov commented 2 weeks ago

I think MultiplyDefinedFragment should be synthetic, without any next / previous fragments. The fragments of the conflicting elements are not fragments of the MultiplyDefinedElement2. It has a fragment at all just because it has to, but there is nothing useful in it.

scheglov commented 2 weeks ago

For MultiplyDefinedFragment the enclosingFragment is... what? Here we can theoretically say that this is the LibraryFragment that has conflicting imports.

https://dart-review.googlesource.com/c/sdk/+/394180