Skip to content

Commit fe83360

Browse files
author
Dart CI
committed
Version 2.11.0-170.0.dev
Merge commit '6fce77010a935c6d8782315c1c805ef47ac5b751' into 'dev'
2 parents c938793 + 6fce770 commit fe83360

File tree

5 files changed

+25
-78
lines changed

5 files changed

+25
-78
lines changed

pkg/analyzer/lib/src/dart/resolver/binary_expression_resolver.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,6 @@ class BinaryExpressionResolver {
106106
);
107107
}
108108

109-
/// Return the static type of the given [expression] that is to be used for
110-
/// type analysis.
111-
///
112-
/// TODO(scheglov) this is duplicate
113-
DartType _getStaticType(Expression expression) {
114-
DartType type = expression.staticType;
115-
return _resolveTypeParameter(type);
116-
}
117-
118109
void _resolveEqual(BinaryExpressionImpl node, {@required bool notEqual}) {
119110
var left = node.leftOperand;
120111
left.accept(_resolver);
@@ -303,7 +294,8 @@ class BinaryExpressionResolver {
303294
return;
304295
}
305296

306-
var leftType = _getStaticType(leftOperand);
297+
var leftType = leftOperand.staticType;
298+
leftType = _resolveTypeParameter(leftType);
307299

308300
if (identical(leftType, NeverTypeImpl.instance)) {
309301
_resolver.errorReporter.reportErrorForNode(
@@ -345,16 +337,21 @@ class BinaryExpressionResolver {
345337
}
346338

347339
void _resolveUserDefinableType(BinaryExpressionImpl node) {
348-
if (identical(node.leftOperand.staticType, NeverTypeImpl.instance)) {
340+
var leftOperand = node.leftOperand;
341+
342+
var leftType = leftOperand.staticType;
343+
leftType = _resolveTypeParameter(leftType);
344+
345+
if (identical(leftType, NeverTypeImpl.instance)) {
349346
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance);
350347
return;
351348
}
352349

353350
DartType staticType =
354351
node.staticInvokeType?.returnType ?? DynamicTypeImpl.instance;
355-
if (node.leftOperand is! ExtensionOverride) {
352+
if (leftOperand is! ExtensionOverride) {
356353
staticType = _typeSystem.refineBinaryExpressionType(
357-
_getStaticType(node.leftOperand),
354+
leftType,
358355
node.operator.type,
359356
node.rightOperand.staticType,
360357
staticType,

pkg/analyzer/lib/src/error/return_type_verifier.dart

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class ReturnTypeVerifier {
152152
// `T` is the declared return type.
153153
// `S` is the static type of the expression.
154154
var T = enclosingExecutable.returnType;
155-
var S = getStaticType(expression);
155+
var S = expression.staticType;
156156

157157
void reportTypeError() {
158158
if (enclosingExecutable.isClosure) {
@@ -253,7 +253,7 @@ class ReturnTypeVerifier {
253253
// `T` is the declared return type.
254254
// `S` is the static type of the expression.
255255
var T = enclosingExecutable.returnType;
256-
var S = getStaticType(expression);
256+
var S = expression.staticType;
257257

258258
void reportTypeError() {
259259
if (enclosingExecutable.isClosure) {
@@ -398,19 +398,6 @@ class ReturnTypeVerifier {
398398
return _typeSystem.isSubtypeOf2(lowerBound, returnType);
399399
}
400400

401-
/// Return the static type of the given [expression] that is to be used for
402-
/// type analysis.
403-
///
404-
/// TODO(scheglov) this is duplicate
405-
static DartType getStaticType(Expression expression) {
406-
DartType type = expression.staticType;
407-
if (type == null) {
408-
// TODO(brianwilkerson) This should never happen.
409-
return DynamicTypeImpl.instance;
410-
}
411-
return type;
412-
}
413-
414401
static bool _isVoidDynamic(DartType type) {
415402
return type.isVoid || type.isDynamic;
416403
}

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

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
15641564
void _checkForArgumentTypeNotAssignableWithExpectedTypes(
15651565
Expression expression, DartType expectedStaticType, ErrorCode errorCode) {
15661566
_checkForArgumentTypeNotAssignable(
1567-
expression, expectedStaticType, getStaticType(expression), errorCode);
1567+
expression, expectedStaticType, expression.staticType, errorCode);
15681568
}
15691569

15701570
/// Verify that the arguments in the given [argumentList] can be assigned to
@@ -1586,7 +1586,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
15861586

15871587
bool _checkForAssignableExpression(
15881588
Expression expression, DartType expectedStaticType, ErrorCode errorCode) {
1589-
DartType actualStaticType = getStaticType(expression);
1589+
DartType actualStaticType = expression.staticType;
15901590
return actualStaticType != null &&
15911591
_checkForAssignableExpressionAtType(
15921592
expression, actualStaticType, expectedStaticType, errorCode);
@@ -2269,7 +2269,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
22692269
return false;
22702270
}
22712271

2272-
DartType iterableType = getStaticType(node.iterable);
2272+
DartType iterableType = node.iterable.staticType;
22732273

22742274
// TODO(scheglov) use NullableDereferenceVerifier
22752275
if (_isNonNullableByDefault) {
@@ -2507,7 +2507,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
25072507
return;
25082508
}
25092509
// test the static type of the expression
2510-
DartType staticType = getStaticType(expression);
2510+
DartType staticType = expression.staticType;
25112511
if (staticType == null) {
25122512
return;
25132513
}
@@ -2948,7 +2948,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
29482948
} else {
29492949
VariableElement leftVariableElement = getVariableElement(lhs);
29502950
leftType = (leftVariableElement == null)
2951-
? getStaticType(lhs)
2951+
? lhs.staticType
29522952
: leftVariableElement.type;
29532953
}
29542954

@@ -3114,7 +3114,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
31143114
void _checkForMissingEnumConstantInSwitch(SwitchStatement statement) {
31153115
// TODO(brianwilkerson) This needs to be checked after constant values have
31163116
// been computed.
3117-
var expressionType = getStaticType(statement.expression);
3117+
var expressionType = statement.expression.staticType;
31183118

31193119
var hasCaseNull = false;
31203120
if (expressionType is InterfaceType) {
@@ -4121,7 +4121,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
41214121
}
41224122

41234123
// prepare 'switch' expression type
4124-
DartType expressionType = getStaticType(expression);
4124+
DartType expressionType = expression.staticType;
41254125
if (expressionType == null) {
41264126
return;
41274127
}
@@ -4134,7 +4134,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
41344134
}
41354135

41364136
Expression caseExpression = switchCase.expression;
4137-
DartType caseType = getStaticType(caseExpression);
4137+
DartType caseType = caseExpression.staticType;
41384138

41394139
// check types
41404140
if (!_typeSystem.isAssignableTo2(expressionType, caseType)) {
@@ -5302,17 +5302,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
53025302
return fields.toList();
53035303
}
53045304

5305-
/// Return the static type of the given [expression] that is to be used for
5306-
/// type analysis.
5307-
static DartType getStaticType(Expression expression) {
5308-
DartType type = expression.staticType;
5309-
if (type == null) {
5310-
// TODO(brianwilkerson) This should never happen.
5311-
return DynamicTypeImpl.instance;
5312-
}
5313-
return type;
5314-
}
5315-
53165305
/// Return the variable element represented by the given [expression], or
53175306
/// `null` if there is no such element.
53185307
static VariableElement getVariableElement(Expression expression) {

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

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
123123
/// the static type of e.
124124
@override
125125
void visitAwaitExpression(AwaitExpression node) {
126-
DartType resultType = _getStaticType(node.expression);
126+
DartType resultType = node.expression.staticType;
127127
if (resultType != null) resultType = _typeSystem.flatten(resultType);
128128
recordStaticType(node, resultType);
129129
}
@@ -140,7 +140,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
140140
/// t;}(e)</i>.</blockquote>
141141
@override
142142
void visitCascadeExpression(CascadeExpression node) {
143-
recordStaticType(node, _getStaticType(node.target));
143+
recordStaticType(node, node.target.staticType);
144144
}
145145

146146
/// The Dart Language Specification, 12.19: <blockquote> ... a conditional expression <i>c</i> of
@@ -257,7 +257,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
257257
@override
258258
void visitNamedExpression(NamedExpression node) {
259259
Expression expression = node.expression;
260-
recordStaticType(node, _getStaticType(expression));
260+
recordStaticType(node, expression.staticType);
261261
}
262262

263263
/// The Dart Language Specification, 12.2: <blockquote>The static type of `null` is bottom.
@@ -270,7 +270,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
270270
@override
271271
void visitParenthesizedExpression(ParenthesizedExpression node) {
272272
Expression expression = node.expression;
273-
recordStaticType(node, _getStaticType(expression));
273+
recordStaticType(node, expression.staticType);
274274
}
275275

276276
/// The Dart Language Specification, 12.9: <blockquote>The static type of a rethrow expression is
@@ -360,32 +360,6 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
360360
recordStaticType(node, staticType);
361361
}
362362

363-
/// Return the static type of the given [expression].
364-
DartType _getStaticType(Expression expression, {bool read = false}) {
365-
DartType type;
366-
if (read) {
367-
type = expression.staticType;
368-
} else {
369-
if (expression is SimpleIdentifier && expression.inSetterContext()) {
370-
var element = expression.staticElement;
371-
if (element is PromotableElement) {
372-
// We're writing to the element so ignore promotions.
373-
type = element.type;
374-
} else {
375-
type = expression.staticType;
376-
}
377-
} else {
378-
type = expression.staticType;
379-
}
380-
}
381-
if (type == null) {
382-
// TODO(brianwilkerson) Determine the conditions for which the static type
383-
// is null.
384-
return _dynamicType;
385-
}
386-
return type;
387-
}
388-
389363
/// Return the type represented by the given type [annotation].
390364
DartType _getType(TypeAnnotation annotation) {
391365
DartType type = annotation.type;

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 11
2929
PATCH 0
30-
PRERELEASE 169
30+
PRERELEASE 170
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)