eb5983869c
`PartElementImpl.enclosingElement3` has static type `Element?`, but in
practice it is always of type `CompilationUnitElementImpl`, due to
this code from `CompilationUnitElementImpl.parts=`:
set parts(List<PartElementImpl> parts) {
for (var part in parts) {
part.enclosingElement3 = this;
var uri = part.uri;
if (uri is DirectiveUriWithUnitImpl) {
uri.unit.enclosingElement3 = this;
}
}
_parts = parts;
}
Therefore, `PartElementImpl.enclosingUnit` can just cast
`enclosingElement3` to the proper type and return it.
This behavior was untested, so I've added a test in
`part_test.dart`. Without the fix, the test throws a `TypeError`.
Change-Id: I3e6f186826aa92cda9c3887c85c5eddc1fea7f31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408641
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>