mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:57:35 +00:00
Remove contextType parameters from methods that don't use them.
All of these methods used to need a `contextType` parameter to pass to the null safety migration tool. Now that the migration tool no longer exists, they can be simplified. Change-Id: Id6b15d88d8b0174022705c00fd524d17007a11e5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351460 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
96f361f0fa
commit
6bd1df749c
|
@ -80,7 +80,7 @@ final class AdjacentStringsImpl extends StringLiteralImpl
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitAdjacentStrings(this, contextType: contextType);
|
||||
resolver.visitAdjacentStrings(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -2028,7 +2028,7 @@ final class BooleanLiteralImpl extends LiteralImpl implements BooleanLiteral {
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitBooleanLiteral(this, contextType: contextType);
|
||||
resolver.visitBooleanLiteral(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -5556,7 +5556,7 @@ final class DoubleLiteralImpl extends LiteralImpl implements DoubleLiteral {
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitDoubleLiteral(this, contextType: contextType);
|
||||
resolver.visitDoubleLiteral(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -10965,7 +10965,7 @@ final class IsExpressionImpl extends ExpressionImpl implements IsExpression {
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitIsExpression(this, contextType: contextType);
|
||||
resolver.visitIsExpression(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -13375,7 +13375,7 @@ final class NullLiteralImpl extends LiteralImpl implements NullLiteral {
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitNullLiteral(this, contextType: contextType);
|
||||
resolver.visitNullLiteral(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -15604,7 +15604,7 @@ final class RethrowExpressionImpl extends ExpressionImpl
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitRethrowExpression(this, contextType: contextType);
|
||||
resolver.visitRethrowExpression(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -16410,7 +16410,7 @@ final class SimpleStringLiteralImpl extends SingleStringLiteralImpl
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitSimpleStringLiteral(this, contextType: contextType);
|
||||
resolver.visitSimpleStringLiteral(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -16677,7 +16677,7 @@ final class StringInterpolationImpl extends SingleStringLiteralImpl
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitStringInterpolation(this, contextType: contextType);
|
||||
resolver.visitStringInterpolation(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -16962,7 +16962,7 @@ final class SuperExpressionImpl extends ExpressionImpl
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitSuperExpression(this, contextType: contextType);
|
||||
resolver.visitSuperExpression(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -17765,7 +17765,7 @@ final class SymbolLiteralImpl extends LiteralImpl implements SymbolLiteral {
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitSymbolLiteral(this, contextType: contextType);
|
||||
resolver.visitSymbolLiteral(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -17900,7 +17900,7 @@ final class ThrowExpressionImpl extends ExpressionImpl
|
|||
|
||||
@override
|
||||
void resolveExpression(ResolverVisitor resolver, DartType contextType) {
|
||||
resolver.visitThrowExpression(this, contextType: contextType);
|
||||
resolver.visitThrowExpression(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -39,10 +39,7 @@ class AssignmentExpressionResolver {
|
|||
|
||||
TypeSystemImpl get _typeSystem => _resolver.typeSystem;
|
||||
|
||||
void resolve(
|
||||
AssignmentExpressionImpl node, {
|
||||
required DartType? contextType,
|
||||
}) {
|
||||
void resolve(AssignmentExpressionImpl node) {
|
||||
var operator = node.operator.type;
|
||||
var hasRead = operator != TokenType.EQ;
|
||||
var isIfNull = operator == TokenType.QUESTION_QUESTION_EQ;
|
||||
|
@ -100,8 +97,7 @@ class AssignmentExpressionResolver {
|
|||
right = _resolver.popRewrite()!;
|
||||
var whyNotPromoted = flow?.whyNotPromoted(right);
|
||||
|
||||
_resolveTypes(node,
|
||||
whyNotPromoted: whyNotPromoted, contextType: contextType);
|
||||
_resolveTypes(node, whyNotPromoted: whyNotPromoted);
|
||||
|
||||
if (flow != null) {
|
||||
if (writeElement is PromotableElement) {
|
||||
|
@ -258,8 +254,7 @@ class AssignmentExpressionResolver {
|
|||
}
|
||||
|
||||
void _resolveTypes(AssignmentExpressionImpl node,
|
||||
{required Map<DartType, NonPromotionReason> Function()? whyNotPromoted,
|
||||
required DartType? contextType}) {
|
||||
{required Map<DartType, NonPromotionReason> Function()? whyNotPromoted}) {
|
||||
DartType assignedType;
|
||||
|
||||
var rightHandSide = node.rightHandSide;
|
||||
|
@ -301,7 +296,7 @@ class AssignmentExpressionResolver {
|
|||
} else {
|
||||
nodeType = assignedType;
|
||||
}
|
||||
_inferenceHelper.recordStaticType(node, nodeType, contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, nodeType);
|
||||
|
||||
// TODO(scheglov): Remove from ErrorVerifier?
|
||||
_checkForInvalidAssignment(
|
||||
|
|
|
@ -43,18 +43,17 @@ class BinaryExpressionResolver {
|
|||
var operator = node.operator.type;
|
||||
|
||||
if (operator == TokenType.AMPERSAND_AMPERSAND) {
|
||||
_resolveLogicalAnd(node, contextType: contextType);
|
||||
_resolveLogicalAnd(node);
|
||||
return;
|
||||
}
|
||||
|
||||
if (operator == TokenType.BANG_EQ || operator == TokenType.EQ_EQ) {
|
||||
_resolveEqual(node,
|
||||
notEqual: operator == TokenType.BANG_EQ, contextType: contextType);
|
||||
_resolveEqual(node, notEqual: operator == TokenType.BANG_EQ);
|
||||
return;
|
||||
}
|
||||
|
||||
if (operator == TokenType.BAR_BAR) {
|
||||
_resolveLogicalOr(node, contextType: contextType);
|
||||
_resolveLogicalOr(node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -77,7 +76,7 @@ class BinaryExpressionResolver {
|
|||
);
|
||||
}
|
||||
|
||||
_resolveUnsupportedOperator(node, contextType: contextType);
|
||||
_resolveUnsupportedOperator(node);
|
||||
}
|
||||
|
||||
void _checkNonBoolOperand(Expression operand, String operator,
|
||||
|
@ -90,8 +89,7 @@ class BinaryExpressionResolver {
|
|||
);
|
||||
}
|
||||
|
||||
void _resolveEqual(BinaryExpressionImpl node,
|
||||
{required bool notEqual, required DartType? contextType}) {
|
||||
void _resolveEqual(BinaryExpressionImpl node, {required bool notEqual}) {
|
||||
_resolver.analyzeExpression(node.leftOperand, null);
|
||||
var left = _resolver.popRewrite()!;
|
||||
|
||||
|
@ -118,7 +116,7 @@ class BinaryExpressionResolver {
|
|||
TokenType.EQ_EQ.lexeme,
|
||||
promoteLeftTypeToNonNull: true,
|
||||
);
|
||||
_resolveUserDefinableType(node, contextType: contextType);
|
||||
_resolveUserDefinableType(node);
|
||||
_resolver.checkForArgumentTypeNotAssignableForArgument(node.rightOperand,
|
||||
promoteParameterToNullable: true, whyNotPromoted: whyNotPromoted);
|
||||
|
||||
|
@ -177,14 +175,12 @@ class BinaryExpressionResolver {
|
|||
var promotedLeftType = _typeSystem.promoteToNonNull(leftType);
|
||||
var staticType = _typeSystem.leastUpperBound(promotedLeftType, rightType);
|
||||
|
||||
_inferenceHelper.recordStaticType(node, staticType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticType);
|
||||
|
||||
_resolver.checkForArgumentTypeNotAssignableForArgument(right);
|
||||
}
|
||||
|
||||
void _resolveLogicalAnd(BinaryExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void _resolveLogicalAnd(BinaryExpressionImpl node) {
|
||||
var left = node.leftOperand;
|
||||
var right = node.rightOperand;
|
||||
var flow = _resolver.flowAnalysis.flow;
|
||||
|
@ -208,12 +204,10 @@ class BinaryExpressionResolver {
|
|||
_checkNonBoolOperand(left, '&&', whyNotPromoted: leftWhyNotPromoted);
|
||||
_checkNonBoolOperand(right, '&&', whyNotPromoted: rightWhyNotPromoted);
|
||||
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType);
|
||||
}
|
||||
|
||||
void _resolveLogicalOr(BinaryExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void _resolveLogicalOr(BinaryExpressionImpl node) {
|
||||
var left = node.leftOperand;
|
||||
var right = node.rightOperand;
|
||||
var flow = _resolver.flowAnalysis.flow;
|
||||
|
@ -237,16 +231,13 @@ class BinaryExpressionResolver {
|
|||
_checkNonBoolOperand(left, '||', whyNotPromoted: leftWhyNotPromoted);
|
||||
_checkNonBoolOperand(right, '||', whyNotPromoted: rightWhyNotPromoted);
|
||||
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType);
|
||||
}
|
||||
|
||||
void _resolveUnsupportedOperator(BinaryExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void _resolveUnsupportedOperator(BinaryExpressionImpl node) {
|
||||
node.leftOperand.accept(_resolver);
|
||||
node.rightOperand.accept(_resolver);
|
||||
_inferenceHelper.recordStaticType(node, InvalidTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, InvalidTypeImpl.instance);
|
||||
}
|
||||
|
||||
void _resolveUserDefinable(BinaryExpressionImpl node,
|
||||
|
@ -283,7 +274,7 @@ class BinaryExpressionResolver {
|
|||
var right = _resolver.popRewrite()!;
|
||||
var whyNotPromoted = _resolver.flowAnalysis.flow?.whyNotPromoted(right);
|
||||
|
||||
_resolveUserDefinableType(node, contextType: contextType);
|
||||
_resolveUserDefinableType(node);
|
||||
_resolver.checkForArgumentTypeNotAssignableForArgument(right,
|
||||
whyNotPromoted: whyNotPromoted);
|
||||
}
|
||||
|
@ -354,8 +345,7 @@ class BinaryExpressionResolver {
|
|||
}
|
||||
}
|
||||
|
||||
void _resolveUserDefinableType(BinaryExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void _resolveUserDefinableType(BinaryExpressionImpl node) {
|
||||
var leftOperand = node.leftOperand;
|
||||
|
||||
DartType leftType;
|
||||
|
@ -367,8 +357,7 @@ class BinaryExpressionResolver {
|
|||
}
|
||||
|
||||
if (identical(leftType, NeverTypeImpl.instance)) {
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -389,7 +378,6 @@ class BinaryExpressionResolver {
|
|||
node.staticElement,
|
||||
);
|
||||
}
|
||||
_inferenceHelper.recordStaticType(node, staticType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,8 +150,7 @@ class FunctionExpressionInvocationResolver {
|
|||
contextType: contextType,
|
||||
).resolveInvocation(rawType: rawType);
|
||||
|
||||
_inferenceHelper.recordStaticType(node, returnType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, returnType);
|
||||
}
|
||||
|
||||
void _resolveReceiverExtensionOverride(FunctionExpressionInvocationImpl node,
|
||||
|
|
|
@ -60,7 +60,7 @@ class FunctionExpressionResolver {
|
|||
// in scope, so we can visit the documentation comment now.
|
||||
parent.documentationComment?.accept(_resolver);
|
||||
}
|
||||
_resolve2(node, imposedType, contextType: contextType);
|
||||
_resolve2(node, imposedType);
|
||||
|
||||
if (_resolver.flowAnalysis.flow != null && !isFunctionDeclaration) {
|
||||
_resolver.checkForBodyMayCompleteNormally(
|
||||
|
@ -153,16 +153,14 @@ class FunctionExpressionResolver {
|
|||
}).toList());
|
||||
}
|
||||
|
||||
void _resolve2(FunctionExpressionImpl node, DartType? imposedType,
|
||||
{required DartType? contextType}) {
|
||||
void _resolve2(FunctionExpressionImpl node, DartType? imposedType) {
|
||||
var functionElement = node.declaredElement as ExecutableElementImpl;
|
||||
|
||||
if (_shouldUpdateReturnType(node)) {
|
||||
functionElement.returnType = imposedType ?? DynamicTypeImpl.instance;
|
||||
}
|
||||
|
||||
_inferenceHelper.recordStaticType(node, functionElement.type,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, functionElement.type);
|
||||
}
|
||||
|
||||
static bool _shouldUpdateReturnType(FunctionExpression node) {
|
||||
|
|
|
@ -68,9 +68,8 @@ class InstanceCreationExpressionResolver {
|
|||
contextType: contextType,
|
||||
whyNotPromotedList: whyNotPromotedList)
|
||||
.resolveInvocation(rawType: elementToInfer?.asType);
|
||||
_resolver.inferenceHelper.recordStaticType(
|
||||
node, node.constructorName.type.type!,
|
||||
contextType: contextType);
|
||||
_resolver.inferenceHelper
|
||||
.recordStaticType(node, node.constructorName.type.type!);
|
||||
_resolver.checkForArgumentTypesNotAssignableInList(
|
||||
node.argumentList, whyNotPromotedList);
|
||||
}
|
||||
|
|
|
@ -147,8 +147,7 @@ class InvocationInferenceHelper {
|
|||
///
|
||||
/// @param expression the node whose type is to be recorded
|
||||
/// @param type the static type of the node
|
||||
void recordStaticType(ExpressionImpl expression, DartType type,
|
||||
{required DartType? contextType}) {
|
||||
void recordStaticType(ExpressionImpl expression, DartType type) {
|
||||
expression.staticType = type;
|
||||
if (_typeSystem.isBottom(type)) {
|
||||
_resolver.flowAnalysis.flow?.handleExit();
|
||||
|
@ -174,6 +173,6 @@ class InvocationInferenceHelper {
|
|||
whyNotPromotedList: whyNotPromotedList,
|
||||
).resolveInvocation(rawType: rawType);
|
||||
|
||||
recordStaticType(node, returnType, contextType: contextType);
|
||||
recordStaticType(node, returnType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,8 +328,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
contextType: contextType,
|
||||
whyNotPromotedList: whyNotPromotedList)
|
||||
.resolveInvocation(rawType: rawType is FunctionType ? rawType : null);
|
||||
_inferenceHelper.recordStaticType(node, staticStaticType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticStaticType);
|
||||
}
|
||||
|
||||
/// Given that we are accessing a property of the given [classElement] with the
|
||||
|
@ -363,8 +362,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
if (getter != null) {
|
||||
nameNode.staticElement = getter;
|
||||
_reportStaticAccessToInstanceMember(getter, nameNode);
|
||||
_rewriteAsFunctionExpressionInvocation(node, getter.returnType,
|
||||
contextType: contextType);
|
||||
_rewriteAsFunctionExpressionInvocation(node, getter.returnType);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -429,8 +427,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
nameNode.staticElement = member;
|
||||
|
||||
if (member is PropertyAccessorElement) {
|
||||
return _rewriteAsFunctionExpressionInvocation(node, member.returnType,
|
||||
contextType: contextType);
|
||||
return _rewriteAsFunctionExpressionInvocation(node, member.returnType);
|
||||
}
|
||||
|
||||
_setResolution(node, member.type, whyNotPromotedList,
|
||||
|
@ -548,8 +545,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
element = multiply.conflictingElements[0];
|
||||
}
|
||||
if (element is PropertyAccessorElement) {
|
||||
return _rewriteAsFunctionExpressionInvocation(node, element.returnType,
|
||||
contextType: contextType);
|
||||
return _rewriteAsFunctionExpressionInvocation(node, element.returnType);
|
||||
}
|
||||
if (element is ExecutableElement) {
|
||||
return _setResolution(node, element.type, whyNotPromotedList,
|
||||
|
@ -559,8 +555,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
_resolver.checkReadOfNotAssignedLocalVariable(nameNode, element);
|
||||
var targetType =
|
||||
_localVariableTypeProvider.getType(nameNode, isRead: true);
|
||||
return _rewriteAsFunctionExpressionInvocation(node, targetType,
|
||||
contextType: contextType);
|
||||
return _rewriteAsFunctionExpressionInvocation(node, targetType);
|
||||
}
|
||||
// TODO(scheglov): This is a questionable distinction.
|
||||
if (element is PrefixElement) {
|
||||
|
@ -634,8 +629,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
}
|
||||
|
||||
if (element is PropertyAccessorElement) {
|
||||
return _rewriteAsFunctionExpressionInvocation(node, element.returnType,
|
||||
contextType: contextType);
|
||||
return _rewriteAsFunctionExpressionInvocation(node, element.returnType);
|
||||
}
|
||||
|
||||
if (element is ExecutableElement) {
|
||||
|
@ -684,7 +678,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
nameNode.staticElement = target;
|
||||
if (target is PropertyAccessorElement) {
|
||||
return _rewriteAsFunctionExpressionInvocation(node, target.returnType,
|
||||
contextType: contextType, isSuperAccess: true);
|
||||
isSuperAccess: true);
|
||||
}
|
||||
_setResolution(node, target.type, whyNotPromotedList,
|
||||
contextType: contextType);
|
||||
|
@ -761,8 +755,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
|
||||
final recordField = result.recordField;
|
||||
if (recordField != null) {
|
||||
return _rewriteAsFunctionExpressionInvocation(node, recordField.type,
|
||||
contextType: contextType);
|
||||
return _rewriteAsFunctionExpressionInvocation(node, recordField.type);
|
||||
}
|
||||
|
||||
var target = result.getter;
|
||||
|
@ -778,8 +771,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
}
|
||||
|
||||
if (target is PropertyAccessorElement) {
|
||||
return _rewriteAsFunctionExpressionInvocation(node, target.returnType,
|
||||
contextType: contextType);
|
||||
return _rewriteAsFunctionExpressionInvocation(node, target.returnType);
|
||||
}
|
||||
return _setResolution(node, target.type, whyNotPromotedList,
|
||||
contextType: contextType);
|
||||
|
@ -825,8 +817,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
nameNode.staticElement = element;
|
||||
if (element is PropertyAccessorElement) {
|
||||
return _rewriteAsFunctionExpressionInvocation(
|
||||
node, element.returnType,
|
||||
contextType: contextType);
|
||||
node, element.returnType);
|
||||
}
|
||||
_setResolution(node, element.type, whyNotPromotedList,
|
||||
contextType: contextType);
|
||||
|
@ -867,7 +858,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
/// [FunctionExpressionInvocation].
|
||||
void _rewriteAsFunctionExpressionInvocation(
|
||||
MethodInvocationImpl node, DartType getterReturnType,
|
||||
{required DartType? contextType, bool isSuperAccess = false}) {
|
||||
{bool isSuperAccess = false}) {
|
||||
var targetType = _typeSystem.resolveToBound(getterReturnType);
|
||||
|
||||
ExpressionImpl functionExpression;
|
||||
|
@ -922,8 +913,7 @@ class MethodInvocationResolver with ScopeHelpers {
|
|||
}
|
||||
functionExpression.staticType = targetType;
|
||||
}
|
||||
_inferenceHelper.recordStaticType(node.methodName, targetType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node.methodName, targetType);
|
||||
|
||||
var invocation = FunctionExpressionInvocationImpl(
|
||||
function: functionExpression,
|
||||
|
|
|
@ -69,7 +69,7 @@ class PostfixExpressionResolver {
|
|||
|
||||
var receiverType = node.readType!;
|
||||
_resolve1(node, receiverType);
|
||||
_resolve2(node, receiverType, contextType: contextType);
|
||||
_resolve2(node, receiverType);
|
||||
}
|
||||
|
||||
/// Check that the result [type] of a prefix or postfix `++` or `--`
|
||||
|
@ -160,13 +160,11 @@ class PostfixExpressionResolver {
|
|||
}
|
||||
}
|
||||
|
||||
void _resolve2(PostfixExpressionImpl node, DartType receiverType,
|
||||
{required DartType? contextType}) {
|
||||
void _resolve2(PostfixExpressionImpl node, DartType receiverType) {
|
||||
Expression operand = node.operand;
|
||||
|
||||
if (identical(receiverType, NeverTypeImpl.instance)) {
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance);
|
||||
} else {
|
||||
DartType operatorReturnType;
|
||||
if (receiverType.isDartCoreInt) {
|
||||
|
@ -186,8 +184,7 @@ class PostfixExpressionResolver {
|
|||
}
|
||||
}
|
||||
|
||||
_inferenceHelper.recordStaticType(node, receiverType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, receiverType);
|
||||
_resolver.nullShortingTermination(node);
|
||||
}
|
||||
|
||||
|
@ -200,10 +197,8 @@ class PostfixExpressionResolver {
|
|||
node,
|
||||
ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR,
|
||||
);
|
||||
_inferenceHelper.recordStaticType(operand, DynamicTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, DynamicTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(operand, DynamicTypeImpl.instance);
|
||||
_inferenceHelper.recordStaticType(node, DynamicTypeImpl.instance);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -217,7 +212,7 @@ class PostfixExpressionResolver {
|
|||
var operandType = operand.typeOrThrow;
|
||||
|
||||
var type = _typeSystem.promoteToNonNull(operandType);
|
||||
_inferenceHelper.recordStaticType(node, type, contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, type);
|
||||
|
||||
_resolver.nullShortingTermination(node);
|
||||
_resolver.flowAnalysis.flow?.nonNullAssert_end(operand);
|
||||
|
|
|
@ -44,7 +44,7 @@ class PrefixExpressionResolver {
|
|||
var operator = node.operator.type;
|
||||
|
||||
if (operator == TokenType.BANG) {
|
||||
_resolveNegation(node, contextType: contextType);
|
||||
_resolveNegation(node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class PrefixExpressionResolver {
|
|||
}
|
||||
|
||||
_resolve1(node);
|
||||
_resolve2(node, contextType: contextType);
|
||||
_resolve2(node);
|
||||
}
|
||||
|
||||
/// Check that the result [type] of a prefix or postfix `++` or `--`
|
||||
|
@ -201,12 +201,11 @@ class PrefixExpressionResolver {
|
|||
}
|
||||
}
|
||||
|
||||
void _resolve2(PrefixExpressionImpl node, {required DartType? contextType}) {
|
||||
void _resolve2(PrefixExpressionImpl node) {
|
||||
TokenType operator = node.operator.type;
|
||||
final readType = node.readType ?? node.operand.staticType;
|
||||
if (identical(readType, NeverTypeImpl.instance)) {
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance);
|
||||
} else {
|
||||
// The other cases are equivalent to invoking a method.
|
||||
DartType staticType;
|
||||
|
@ -234,14 +233,12 @@ class PrefixExpressionResolver {
|
|||
}
|
||||
}
|
||||
}
|
||||
_inferenceHelper.recordStaticType(node, staticType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticType);
|
||||
}
|
||||
_resolver.nullShortingTermination(node);
|
||||
}
|
||||
|
||||
void _resolveNegation(PrefixExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void _resolveNegation(PrefixExpressionImpl node) {
|
||||
var operand = node.operand;
|
||||
|
||||
_resolver.analyzeExpression(operand, _typeProvider.boolType);
|
||||
|
@ -251,8 +248,7 @@ class PrefixExpressionResolver {
|
|||
_resolver.boolExpressionVerifier.checkForNonBoolNegationExpression(operand,
|
||||
whyNotPromoted: whyNotPromoted);
|
||||
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType);
|
||||
|
||||
_resolver.flowAnalysis.flow?.logicalNot_end(node, operand);
|
||||
}
|
||||
|
|
|
@ -65,10 +65,8 @@ class PrefixedIdentifierResolver {
|
|||
}
|
||||
|
||||
if (identical(node.prefix.staticType, NeverTypeImpl.instance)) {
|
||||
_inferenceHelper.recordStaticType(identifier, NeverTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(identifier, NeverTypeImpl.instance);
|
||||
_inferenceHelper.recordStaticType(node, NeverTypeImpl.instance);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -122,8 +120,8 @@ class PrefixedIdentifierResolver {
|
|||
type = _inferenceHelper.inferTearOff(node, identifier, type,
|
||||
contextType: contextType);
|
||||
}
|
||||
_inferenceHelper.recordStaticType(identifier, type, contextType: null);
|
||||
_inferenceHelper.recordStaticType(node, type, contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(identifier, type);
|
||||
_inferenceHelper.recordStaticType(node, type);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ class RecordLiteralResolver {
|
|||
required DartType? contextType,
|
||||
}) {
|
||||
_resolveFields(node, contextType);
|
||||
_buildType(node, contextType);
|
||||
_buildType(node);
|
||||
|
||||
_reportDuplicateFieldDefinitions(node);
|
||||
_reportInvalidFieldNames(node);
|
||||
}
|
||||
|
||||
void _buildType(RecordLiteralImpl node, DartType? contextType) {
|
||||
void _buildType(RecordLiteralImpl node) {
|
||||
final positionalFields = <RecordTypePositionalFieldImpl>[];
|
||||
final namedFields = <RecordTypeNamedFieldImpl>[];
|
||||
for (final field in node.fields) {
|
||||
|
@ -62,7 +62,6 @@ class RecordLiteralResolver {
|
|||
namedFields: namedFields,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
),
|
||||
contextType: contextType,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,16 +175,14 @@ class SimpleIdentifierResolver with ScopeHelpers {
|
|||
if (callFunctionType != null) {
|
||||
final staticType = _resolver.inferenceHelper
|
||||
.inferTearOff(node, node, callFunctionType, contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticType);
|
||||
_currentAlreadyResolved = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
final recordField = result.recordField;
|
||||
if (recordField != null) {
|
||||
_inferenceHelper.recordStaticType(node, recordField.type,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, recordField.type);
|
||||
_currentAlreadyResolved = true;
|
||||
return null;
|
||||
}
|
||||
|
@ -290,8 +288,7 @@ class SimpleIdentifierResolver with ScopeHelpers {
|
|||
staticType = _resolver.inferenceHelper
|
||||
.inferTearOff(node, node, staticType, contextType: contextType);
|
||||
}
|
||||
_inferenceHelper.recordStaticType(node, staticType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticType);
|
||||
}
|
||||
|
||||
// TODO(scheglov): this is duplicate
|
||||
|
|
|
@ -1739,11 +1739,10 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitAdjacentStrings(AdjacentStrings node, {DartType? contextType}) {
|
||||
void visitAdjacentStrings(AdjacentStrings node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitAdjacentStrings(node as AdjacentStringsImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitAdjacentStrings(node as AdjacentStringsImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1778,7 +1777,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
|
||||
node.type.accept(this);
|
||||
|
||||
typeAnalyzer.visitAsExpression(node, contextType: contextType);
|
||||
typeAnalyzer.visitAsExpression(node);
|
||||
flowAnalysis.asExpression(node);
|
||||
_insertImplicitCallReference(
|
||||
insertGenericFunctionInstantiation(node, contextType: contextType),
|
||||
|
@ -1838,8 +1837,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
void visitAssignmentExpression(AssignmentExpression node,
|
||||
{DartType? contextType}) {
|
||||
checkUnreachableNode(node);
|
||||
_assignmentExpressionResolver.resolve(node as AssignmentExpressionImpl,
|
||||
contextType: contextType);
|
||||
_assignmentExpressionResolver.resolve(node as AssignmentExpressionImpl);
|
||||
_insertImplicitCallReference(
|
||||
insertGenericFunctionInstantiation(node, contextType: contextType),
|
||||
contextType: contextType);
|
||||
|
@ -1862,8 +1860,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
checkUnreachableNode(node);
|
||||
analyzeExpression(node.expression, futureUnion);
|
||||
popRewrite();
|
||||
typeAnalyzer.visitAwaitExpression(node as AwaitExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitAwaitExpression(node as AwaitExpressionImpl);
|
||||
_insertImplicitCallReference(
|
||||
insertGenericFunctionInstantiation(node, contextType: contextType),
|
||||
contextType: contextType);
|
||||
|
@ -1901,12 +1898,11 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitBooleanLiteral(BooleanLiteral node, {DartType? contextType}) {
|
||||
void visitBooleanLiteral(BooleanLiteral node) {
|
||||
flowAnalysis.flow?.booleanLiteral(node, node.value);
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitBooleanLiteral(node as BooleanLiteralImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitBooleanLiteral(node as BooleanLiteralImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1937,7 +1933,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
|
||||
node.cascadeSections.accept(this);
|
||||
|
||||
typeAnalyzer.visitCascadeExpression(node, contextType: contextType);
|
||||
typeAnalyzer.visitCascadeExpression(node);
|
||||
|
||||
nullShortingTermination(node);
|
||||
flowAnalysis.flow!.cascadeExpression_end(node);
|
||||
|
@ -2048,8 +2044,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
elseExpression = popRewrite()!;
|
||||
|
||||
typeAnalyzer.visitConditionalExpression(node as ConditionalExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitConditionalExpression(node as ConditionalExpressionImpl);
|
||||
if (flow != null) {
|
||||
flow.conditional_end(
|
||||
node, node.typeOrThrow, elseExpression, elseExpression.typeOrThrow);
|
||||
|
@ -2201,11 +2196,10 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitDoubleLiteral(DoubleLiteral node, {DartType? contextType}) {
|
||||
void visitDoubleLiteral(DoubleLiteral node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitDoubleLiteral(node as DoubleLiteralImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitDoubleLiteral(node as DoubleLiteralImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -2736,7 +2730,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
} else {
|
||||
type = InvalidTypeImpl.instance;
|
||||
}
|
||||
inferenceHelper.recordStaticType(node, type, contextType: contextType);
|
||||
inferenceHelper.recordStaticType(node, type);
|
||||
var replacement =
|
||||
insertGenericFunctionInstantiation(node, contextType: contextType);
|
||||
|
||||
|
@ -2775,10 +2769,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitIsExpression(
|
||||
covariant IsExpressionImpl node, {
|
||||
DartType? contextType,
|
||||
}) {
|
||||
void visitIsExpression(covariant IsExpressionImpl node) {
|
||||
checkUnreachableNode(node);
|
||||
|
||||
analyzeExpression(node.expression, null);
|
||||
|
@ -2786,7 +2777,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
|
||||
node.type.accept(this);
|
||||
|
||||
typeAnalyzer.visitIsExpression(node, contextType: contextType);
|
||||
typeAnalyzer.visitIsExpression(node);
|
||||
flowAnalysis.isExpression(node);
|
||||
}
|
||||
|
||||
|
@ -2943,8 +2934,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
node.name.accept(this);
|
||||
analyzeExpression(node.expression, contextType);
|
||||
popRewrite();
|
||||
typeAnalyzer.visitNamedExpression(node as NamedExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitNamedExpression(node as NamedExpressionImpl);
|
||||
// Any "why not promoted" information that flow analysis had associated with
|
||||
// `node.expression` now needs to be forwarded to `node`, so that when
|
||||
// `visitArgumentList` iterates through the arguments, it will find it.
|
||||
|
@ -2975,10 +2965,9 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitNullLiteral(NullLiteral node, {DartType? contextType}) {
|
||||
void visitNullLiteral(NullLiteral node) {
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitNullLiteral(node as NullLiteralImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitNullLiteral(node as NullLiteralImpl);
|
||||
flowAnalysis.flow?.nullLiteral(node, node.typeOrThrow);
|
||||
checkUnreachableNode(node);
|
||||
}
|
||||
|
@ -2995,9 +2984,8 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
checkUnreachableNode(node);
|
||||
analyzeExpression(node.expression, contextType);
|
||||
popRewrite();
|
||||
typeAnalyzer.visitParenthesizedExpression(
|
||||
node as ParenthesizedExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer
|
||||
.visitParenthesizedExpression(node as ParenthesizedExpressionImpl);
|
||||
flowAnalysis.flow?.parenthesizedExpression(node, node.expression);
|
||||
}
|
||||
|
||||
|
@ -3139,8 +3127,8 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
contextType: contextType);
|
||||
}
|
||||
|
||||
inferenceHelper.recordStaticType(propertyName, type, contextType: null);
|
||||
inferenceHelper.recordStaticType(node, type, contextType: contextType);
|
||||
inferenceHelper.recordStaticType(propertyName, type);
|
||||
inferenceHelper.recordStaticType(node, type);
|
||||
var replacement =
|
||||
insertGenericFunctionInstantiation(node, contextType: contextType);
|
||||
|
||||
|
@ -3223,11 +3211,10 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitRethrowExpression(RethrowExpression node, {DartType? contextType}) {
|
||||
void visitRethrowExpression(RethrowExpression node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitRethrowExpression(node as RethrowExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitRethrowExpression(node as RethrowExpressionImpl);
|
||||
flowAnalysis.flow?.handleExit();
|
||||
}
|
||||
|
||||
|
@ -3275,12 +3262,10 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitSimpleStringLiteral(SimpleStringLiteral node,
|
||||
{DartType? contextType}) {
|
||||
void visitSimpleStringLiteral(SimpleStringLiteral node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitSimpleStringLiteral(node as SimpleStringLiteralImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitSimpleStringLiteral(node as SimpleStringLiteralImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -3303,12 +3288,10 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitStringInterpolation(StringInterpolation node,
|
||||
{DartType? contextType}) {
|
||||
void visitStringInterpolation(StringInterpolation node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitStringInterpolation(node as StringInterpolationImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitStringInterpolation(node as StringInterpolationImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -3333,12 +3316,11 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitSuperExpression(SuperExpression node, {DartType? contextType}) {
|
||||
void visitSuperExpression(SuperExpression node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
elementResolver.visitSuperExpression(node);
|
||||
typeAnalyzer.visitSuperExpression(node as SuperExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitSuperExpression(node as SuperExpressionImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -3370,28 +3352,25 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
|
||||
@override
|
||||
void visitSymbolLiteral(SymbolLiteral node, {DartType? contextType}) {
|
||||
void visitSymbolLiteral(SymbolLiteral node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitSymbolLiteral(node as SymbolLiteralImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitSymbolLiteral(node as SymbolLiteralImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitThisExpression(ThisExpression node, {DartType? contextType}) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitThisExpression(node as ThisExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitThisExpression(node as ThisExpressionImpl);
|
||||
_insertImplicitCallReference(node, contextType: contextType);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitThrowExpression(ThrowExpression node, {DartType? contextType}) {
|
||||
void visitThrowExpression(ThrowExpression node) {
|
||||
checkUnreachableNode(node);
|
||||
node.visitChildren(this);
|
||||
typeAnalyzer.visitThrowExpression(node as ThrowExpressionImpl,
|
||||
contextType: contextType);
|
||||
typeAnalyzer.visitThrowExpression(node as ThrowExpressionImpl);
|
||||
flowAnalysis.flow?.handleExit();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,10 +46,8 @@ class StaticTypeAnalyzer {
|
|||
|
||||
/// The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is
|
||||
/// `String`.</blockquote>
|
||||
void visitAdjacentStrings(covariant AdjacentStringsImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.stringType,
|
||||
contextType: contextType);
|
||||
void visitAdjacentStrings(covariant AdjacentStringsImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.stringType);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.32: <blockquote>... the cast expression <i>e as T</i> ...
|
||||
|
@ -58,39 +56,31 @@ class StaticTypeAnalyzer {
|
|||
/// scope.
|
||||
///
|
||||
/// The static type of a cast expression <i>e as T</i> is <i>T</i>.</blockquote>
|
||||
void visitAsExpression(covariant AsExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _getType(node.type),
|
||||
contextType: contextType);
|
||||
void visitAsExpression(covariant AsExpressionImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _getType(node.type));
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 16.29 (Await Expressions):
|
||||
///
|
||||
/// The static type of [the expression "await e"] is flatten(T) where T is
|
||||
/// the static type of e.
|
||||
void visitAwaitExpression(covariant AwaitExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void visitAwaitExpression(covariant AwaitExpressionImpl node) {
|
||||
var resultType = node.expression.typeOrThrow;
|
||||
resultType = _typeSystem.flatten(resultType);
|
||||
_inferenceHelper.recordStaticType(node, resultType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, resultType);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.4: <blockquote>The static type of a boolean literal is
|
||||
/// bool.</blockquote>
|
||||
void visitBooleanLiteral(covariant BooleanLiteralImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType,
|
||||
contextType: contextType);
|
||||
void visitBooleanLiteral(covariant BooleanLiteralImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.15.2: <blockquote>A cascaded method invocation expression
|
||||
/// of the form <i>e..suffix</i> is equivalent to the expression <i>(t) {t.suffix; return
|
||||
/// t;}(e)</i>.</blockquote>
|
||||
void visitCascadeExpression(covariant CascadeExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, node.target.typeOrThrow,
|
||||
contextType: contextType);
|
||||
void visitCascadeExpression(covariant CascadeExpressionImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, node.target.typeOrThrow);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.19: <blockquote> ... a conditional expression <i>c</i> of
|
||||
|
@ -100,21 +90,17 @@ class StaticTypeAnalyzer {
|
|||
///
|
||||
/// The static type of <i>c</i> is the least upper bound of the static type of <i>e<sub>2</sub></i>
|
||||
/// and the static type of <i>e<sub>3</sub></i>.</blockquote>
|
||||
void visitConditionalExpression(covariant ConditionalExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void visitConditionalExpression(covariant ConditionalExpressionImpl node) {
|
||||
DartType staticType = _typeSystem.leastUpperBound(
|
||||
node.thenExpression.typeOrThrow, node.elseExpression.typeOrThrow);
|
||||
|
||||
_inferenceHelper.recordStaticType(node, staticType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, staticType);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.3: <blockquote>The static type of a literal double is
|
||||
/// double.</blockquote>
|
||||
void visitDoubleLiteral(covariant DoubleLiteralImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.doubleType,
|
||||
contextType: contextType);
|
||||
void visitDoubleLiteral(covariant DoubleLiteralImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.doubleType);
|
||||
}
|
||||
|
||||
void visitExtensionOverride(ExtensionOverride node) {
|
||||
|
@ -180,11 +166,9 @@ class StaticTypeAnalyzer {
|
|||
strictCasts: strictCasts) ||
|
||||
!_typeSystem.isAssignableTo(_typeProvider.doubleType, contextType,
|
||||
strictCasts: strictCasts)) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.intType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.intType);
|
||||
} else {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.doubleType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.doubleType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,64 +176,50 @@ class StaticTypeAnalyzer {
|
|||
/// denote a type available in the current lexical scope.
|
||||
///
|
||||
/// The static type of an is-expression is `bool`.</blockquote>
|
||||
void visitIsExpression(covariant IsExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType,
|
||||
contextType: contextType);
|
||||
void visitIsExpression(covariant IsExpressionImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.boolType);
|
||||
}
|
||||
|
||||
void visitMethodInvocation(MethodInvocation node) {
|
||||
throw StateError('Should not be invoked');
|
||||
}
|
||||
|
||||
void visitNamedExpression(covariant NamedExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void visitNamedExpression(covariant NamedExpressionImpl node) {
|
||||
Expression expression = node.expression;
|
||||
_inferenceHelper.recordStaticType(node, expression.typeOrThrow,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, expression.typeOrThrow);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.2: <blockquote>The static type of `null` is bottom.
|
||||
/// </blockquote>
|
||||
void visitNullLiteral(covariant NullLiteralImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.nullType,
|
||||
contextType: contextType);
|
||||
void visitNullLiteral(covariant NullLiteralImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.nullType);
|
||||
}
|
||||
|
||||
void visitParenthesizedExpression(covariant ParenthesizedExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void visitParenthesizedExpression(
|
||||
covariant ParenthesizedExpressionImpl node) {
|
||||
Expression expression = node.expression;
|
||||
_inferenceHelper.recordStaticType(node, expression.typeOrThrow,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, expression.typeOrThrow);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.9: <blockquote>The static type of a rethrow expression is
|
||||
/// bottom.</blockquote>
|
||||
void visitRethrowExpression(covariant RethrowExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.bottomType,
|
||||
contextType: contextType);
|
||||
void visitRethrowExpression(covariant RethrowExpressionImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.bottomType);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is
|
||||
/// `String`.</blockquote>
|
||||
void visitSimpleStringLiteral(covariant SimpleStringLiteralImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.stringType,
|
||||
contextType: contextType);
|
||||
void visitSimpleStringLiteral(covariant SimpleStringLiteralImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.stringType);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is
|
||||
/// `String`.</blockquote>
|
||||
void visitStringInterpolation(covariant StringInterpolationImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.stringType,
|
||||
contextType: contextType);
|
||||
void visitStringInterpolation(covariant StringInterpolationImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.stringType);
|
||||
}
|
||||
|
||||
void visitSuperExpression(covariant SuperExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void visitSuperExpression(covariant SuperExpressionImpl node) {
|
||||
var thisType = _resolver.thisType;
|
||||
_resolver.flowAnalysis.flow
|
||||
?.thisOrSuper(node, thisType ?? _dynamicType, isSuper: true);
|
||||
|
@ -257,44 +227,35 @@ class StaticTypeAnalyzer {
|
|||
node.thisOrAncestorOfType<ExtensionDeclaration>() != null) {
|
||||
// TODO(brianwilkerson): Report this error if it hasn't already been
|
||||
// reported.
|
||||
_inferenceHelper.recordStaticType(node, InvalidTypeImpl.instance,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, InvalidTypeImpl.instance);
|
||||
} else {
|
||||
_inferenceHelper.recordStaticType(node, thisType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, thisType);
|
||||
}
|
||||
}
|
||||
|
||||
void visitSymbolLiteral(covariant SymbolLiteralImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.symbolType,
|
||||
contextType: contextType);
|
||||
void visitSymbolLiteral(covariant SymbolLiteralImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.symbolType);
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.10: <blockquote>The static type of `this` is the
|
||||
/// interface of the immediately enclosing class.</blockquote>
|
||||
void visitThisExpression(covariant ThisExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
void visitThisExpression(covariant ThisExpressionImpl node) {
|
||||
var thisType = _resolver.thisType;
|
||||
_resolver.flowAnalysis.flow
|
||||
?.thisOrSuper(node, thisType ?? _dynamicType, isSuper: false);
|
||||
if (thisType == null) {
|
||||
// TODO(brianwilkerson): Report this error if it hasn't already been
|
||||
// reported.
|
||||
_inferenceHelper.recordStaticType(node, _dynamicType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, _dynamicType);
|
||||
} else {
|
||||
_inferenceHelper.recordStaticType(node, thisType,
|
||||
contextType: contextType);
|
||||
_inferenceHelper.recordStaticType(node, thisType);
|
||||
}
|
||||
}
|
||||
|
||||
/// The Dart Language Specification, 12.8: <blockquote>The static type of a throw expression is
|
||||
/// bottom.</blockquote>
|
||||
void visitThrowExpression(covariant ThrowExpressionImpl node,
|
||||
{required DartType? contextType}) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.bottomType,
|
||||
contextType: contextType);
|
||||
void visitThrowExpression(covariant ThrowExpressionImpl node) {
|
||||
_inferenceHelper.recordStaticType(node, _typeProvider.bottomType);
|
||||
}
|
||||
|
||||
/// Return the type represented by the given type [annotation].
|
||||
|
|
Loading…
Reference in a new issue