Skip to content

Commit 4d30d9c

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
1 parent 7693da7 commit 4d30d9c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Deprecated InheritanceManager2, and replaced with InheritanceManager3.
1515
InheritanceManager3 returns ExecutableElements, not FunctionType(s).
1616
* Added the optional parameter `path` to `parseString`.
17+
* Changed `TypeSystem.resolveToBound(DartType)` implementation to do
18+
what its documentation says.
1719

1820
## 0.37.0
1921
* Removed deprecated getter `DartType.isUndefined`.

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)