Skip to content

Commit df9267d

Browse files
fshcheglovCommit Queue
authored andcommitted
Make FragmentedElementMixin and TypeParameterElementImpl get baseElement more precise
Change-Id: I4fe7140b72a0576c59087a9148c62ee1b93c1553 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440540 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 5229f45 commit df9267d

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,8 +2960,8 @@ class FieldFragmentImpl extends PropertyInducingFragmentImpl
29602960

29612961
class FormalParameterElementImpl extends PromotableElementImpl
29622962
with
2963-
FragmentedAnnotatableElementMixin<FormalParameterFragment>,
2964-
FragmentedElementMixin<FormalParameterFragment>,
2963+
FragmentedAnnotatableElementMixin<FormalParameterFragmentImpl>,
2964+
FragmentedElementMixin<FormalParameterFragmentImpl>,
29652965
FormalParameterElementMixin,
29662966
_HasSinceSdkVersionMixin,
29672967
_NonTopLevelVariableOrParameter {
@@ -3413,7 +3413,7 @@ class FormalParameterFragmentImpl extends VariableFragmentImpl
34133413
) => FormalParameterElementImpl(firstFragment as FormalParameterFragmentImpl);
34143414
}
34153415

3416-
mixin FragmentedAnnotatableElementMixin<E extends Fragment>
3416+
mixin FragmentedAnnotatableElementMixin<E extends FragmentImpl>
34173417
implements FragmentedElementMixin<E> {
34183418
String? get documentationComment {
34193419
var buffer = StringBuffer();
@@ -3457,14 +3457,9 @@ mixin FragmentedAnnotatableElementMixin<E extends Fragment>
34573457
}
34583458
}
34593459

3460-
mixin FragmentedElementMixin<E extends Fragment> implements _Fragmented<E> {
3460+
mixin FragmentedElementMixin<E extends FragmentImpl> implements _Fragmented<E> {
34613461
bool get isSynthetic {
3462-
if (firstFragment is FragmentImpl) {
3463-
return (firstFragment as FragmentImpl).isSynthetic;
3464-
}
3465-
// We should never get to this point.
3466-
assert(false, 'Fragment does not implement ElementImpl');
3467-
return false;
3462+
return firstFragment.isSynthetic;
34683463
}
34693464

34703465
/// A list of all of the fragments from which this element is composed.
@@ -3520,9 +3515,7 @@ mixin FragmentedExecutableElementMixin<E extends ExecutableFragmentImpl>
35203515
bool get isStatic => (firstFragment as ExecutableFragmentImpl).isStatic;
35213516
}
35223517

3523-
mixin FragmentedTypeParameterizedElementMixin<
3524-
E extends TypeParameterizedFragment
3525-
>
3518+
mixin FragmentedTypeParameterizedElementMixin<E extends FragmentImpl>
35263519
implements FragmentedElementMixin<E> {
35273520
bool get isSimplyBounded {
35283521
var fragment = firstFragment;
@@ -9591,8 +9584,8 @@ class TopLevelVariableFragmentImpl extends PropertyInducingFragmentImpl
95919584

95929585
class TypeAliasElementImpl extends TypeDefiningElementImpl
95939586
with
9594-
FragmentedAnnotatableElementMixin<TypeAliasFragment>,
9595-
FragmentedElementMixin<TypeAliasFragment>,
9587+
FragmentedAnnotatableElementMixin<TypeAliasFragmentImpl>,
9588+
FragmentedElementMixin<TypeAliasFragmentImpl>,
95969589
DeferredResolutionReadingMixin,
95979590
_HasSinceSdkVersionMixin
95989591
implements AnnotatableElementImpl, TypeAliasElement {
@@ -9926,8 +9919,8 @@ abstract class TypeDefiningElementImpl extends ElementImpl
99269919

99279920
class TypeParameterElementImpl extends TypeDefiningElementImpl
99289921
with
9929-
FragmentedAnnotatableElementMixin<TypeParameterFragment>,
9930-
FragmentedElementMixin<TypeParameterFragment>,
9922+
FragmentedAnnotatableElementMixin<TypeParameterFragmentImpl>,
9923+
FragmentedElementMixin<TypeParameterFragmentImpl>,
99319924
_NonTopLevelVariableOrParameter
99329925
implements TypeParameterElement, SharedTypeParameter {
99339926
@override
@@ -9950,7 +9943,7 @@ class TypeParameterElementImpl extends TypeDefiningElementImpl
99509943
}
99519944

99529945
@override
9953-
TypeParameterElement get baseElement => this;
9946+
TypeParameterElementImpl get baseElement => this;
99549947

99559948
@override
99569949
TypeImpl? get bound => firstFragment.bound;

pkg/analyzer/lib/src/dart/element/type_system.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ class TypeSystemImpl implements TypeSystem {
17891789
if (isSubtypeOf(to, from.bound)) {
17901790
var declaration = from.element.baseElement;
17911791
return TypeParameterTypeImpl(
1792-
element: declaration as TypeParameterElementImpl,
1792+
element: declaration,
17931793
nullabilitySuffix: _promotedTypeParameterTypeNullability(
17941794
from.nullabilitySuffix,
17951795
to.nullabilitySuffix,

0 commit comments

Comments
 (0)