Inline `_analyzeLeastUpperBoundTypes` and `_analyzeLeastUpperBound`.
These two methods were each called from exactly one place, and did
very little beyond plumbing. It's clearer just to inline them directly
in their caller, `visitConditionalExpression`.
Change-Id: Ia10b69fc2f0817319ca93c0f12b1b148ac179f33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350682
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index dba2f3f..5b671e8 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -102,7 +102,10 @@
/// and the static type of <i>e<sub>3</sub></i>.</blockquote>
void visitConditionalExpression(covariant ConditionalExpressionImpl node,
{required DartType? contextType}) {
- _analyzeLeastUpperBound(node, node.thenExpression, node.elseExpression,
+ DartType staticType = _typeSystem.leastUpperBound(
+ node.thenExpression.typeOrThrow, node.elseExpression.typeOrThrow);
+
+ _inferenceHelper.recordStaticType(node, staticType,
contextType: contextType);
}
@@ -294,29 +297,6 @@
contextType: contextType);
}
- /// Set the static type of [node] to be the least upper bound of the static
- /// types of subexpressions [expr1] and [expr2].
- void _analyzeLeastUpperBound(
- ExpressionImpl node, Expression expr1, Expression expr2,
- {required DartType? contextType}) {
- var staticType1 = expr1.typeOrThrow;
- var staticType2 = expr2.typeOrThrow;
-
- _analyzeLeastUpperBoundTypes(node, staticType1, staticType2,
- contextType: contextType);
- }
-
- /// Set the static type of [node] to be the least upper bound of the static
- /// types [staticType1] and [staticType2].
- void _analyzeLeastUpperBoundTypes(
- ExpressionImpl node, DartType staticType1, DartType staticType2,
- {required DartType? contextType}) {
- DartType staticType = _typeSystem.leastUpperBound(staticType1, staticType2);
-
- _inferenceHelper.recordStaticType(node, staticType,
- contextType: contextType);
- }
-
/// Return the type represented by the given type [annotation].
DartType _getType(TypeAnnotation annotation) {
var type = annotation.type;