Skip to content

Commit 7d54324

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Make TypeSystem.resolveToBound() do what it promised in the documentation.
OTOH, we don't have TypeSystem.instantiateToBounds(), so I'm not 100% sure whether the doc is inaccurate, or instantiateToBounds() should be added. Or even if DartType.resolveToBound() should be used, not the version from TypeSystem. [email protected], [email protected] Change-Id: Ied333161d68af40314f4b8e2c3cee3b350d05f7c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110757 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 06d4cd3 commit 7d54324

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2633,7 +2633,31 @@ abstract class TypeSystem implements public.TypeSystem {
26332633

26342634
@override
26352635
DartType resolveToBound(DartType type) {
2636-
return instantiateToBounds(type);
2636+
if (type is TypeParameterTypeImpl) {
2637+
var element = type.element;
2638+
2639+
var bound = element.bound as TypeImpl;
2640+
if (bound == null) {
2641+
return typeProvider.objectType;
2642+
}
2643+
2644+
NullabilitySuffix nullabilitySuffix = type.nullabilitySuffix;
2645+
NullabilitySuffix newNullabilitySuffix;
2646+
if (nullabilitySuffix == NullabilitySuffix.question ||
2647+
bound.nullabilitySuffix == NullabilitySuffix.question) {
2648+
newNullabilitySuffix = NullabilitySuffix.question;
2649+
} else if (nullabilitySuffix == NullabilitySuffix.star ||
2650+
bound.nullabilitySuffix == NullabilitySuffix.star) {
2651+
newNullabilitySuffix = NullabilitySuffix.star;
2652+
} else {
2653+
newNullabilitySuffix = NullabilitySuffix.none;
2654+
}
2655+
2656+
var resolved = resolveToBound(bound) as TypeImpl;
2657+
return resolved.withNullability(newNullabilitySuffix);
2658+
}
2659+
2660+
return type;
26372661
}
26382662

26392663
/**

0 commit comments

Comments
 (0)