diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index 2599943d08df..cd2d3139a2f4 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -2092,7 +2092,7 @@ abstract class BodyBuilder extends ScopeListener isConst: isConst) ..fileOffset = identifier.charOffset ..fileEqualsOffset = offsetForToken(equalsToken); - library.checkBoundsInVariableDeclaration(variable, typeEnvironment); + library.checkBoundsInVariableDeclaration(variable, typeEnvironment, uri); push(variable); } @@ -2464,7 +2464,7 @@ abstract class BodyBuilder extends ScopeListener leftBracket, expressions, rightBracket); - library.checkBoundsInListLiteral(node, typeEnvironment); + library.checkBoundsInListLiteral(node, typeEnvironment, uri); push(node); } @@ -2503,7 +2503,7 @@ abstract class BodyBuilder extends ScopeListener leftBrace, expressions, leftBrace.endGroup); - library.checkBoundsInSetLiteral(node, typeEnvironment); + library.checkBoundsInSetLiteral(node, typeEnvironment, uri); if (!library.loader.target.enableSetLiterals) { internalProblem( fasta.messageSetLiteralsNotSupported, node.fileOffset, uri); @@ -2627,7 +2627,7 @@ abstract class BodyBuilder extends ScopeListener leftBrace, entries, leftBrace.endGroup); - library.checkBoundsInMapLiteral(node, typeEnvironment); + library.checkBoundsInMapLiteral(node, typeEnvironment, uri); push(node); } @@ -2793,7 +2793,7 @@ abstract class BodyBuilder extends ScopeListener void handleAsOperator(Token operator) { debugEvent("AsOperator"); DartType type = buildDartType(pop()); - library.checkBoundsInType(type, typeEnvironment, operator.charOffset); + library.checkBoundsInType(type, typeEnvironment, uri, operator.charOffset); Expression expression = popForValue(); if (!library.loader.target.enableConstantUpdate2018 && constantContext != ConstantContext.none) { @@ -2815,7 +2815,8 @@ abstract class BodyBuilder extends ScopeListener bool isInverted = not != null; Expression isExpression = forest.isExpression(operand, isOperator, not, type); - library.checkBoundsInType(type, typeEnvironment, isOperator.charOffset); + library.checkBoundsInType( + type, typeEnvironment, uri, isOperator.charOffset); if (operand is VariableGet) { typePromoter?.handleIsCheck(isExpression, isInverted, operand.variable, type, functionNestingLevel); @@ -3372,7 +3373,7 @@ abstract class BodyBuilder extends ScopeListener target, forest.castArguments(arguments), isConst: isConst) ..fileOffset = charOffset; - library.checkBoundsInConstructorInvocation(node, typeEnvironment); + library.checkBoundsInConstructorInvocation(node, typeEnvironment, uri); return node; } else { Procedure procedure = target; @@ -3392,14 +3393,14 @@ abstract class BodyBuilder extends ScopeListener target, forest.castArguments(arguments), isConst: isConst) ..fileOffset = charOffset; - library.checkBoundsInFactoryInvocation(node, typeEnvironment); + library.checkBoundsInFactoryInvocation(node, typeEnvironment, uri); return node; } else { StaticInvocation node = new StaticInvocation( target, forest.castArguments(arguments), isConst: isConst) ..fileOffset = charOffset; - library.checkBoundsInStaticInvocation(node, typeEnvironment); + library.checkBoundsInStaticInvocation(node, typeEnvironment, uri); return node; } } diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart index 830e13a9d110..7b2f7f549ce2 100644 --- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart +++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart @@ -183,7 +183,7 @@ class InferenceVisitor extends BodyVisitor1 { KernelLibraryBuilder library = inferrer.library; if (!hasExplicitTypeArguments) { library.checkBoundsInConstructorInvocation( - node, inferrer.typeSchemaEnvironment, + node, inferrer.typeSchemaEnvironment, inferrer.helper.uri, inferred: true); } } @@ -244,7 +244,7 @@ class InferenceVisitor extends BodyVisitor1 { KernelLibraryBuilder library = inferrer.library; if (!hadExplicitTypeArguments) { library.checkBoundsInFactoryInvocation( - node, inferrer.typeSchemaEnvironment, + node, inferrer.typeSchemaEnvironment, inferrer.helper.uri, inferred: true); } } @@ -919,7 +919,8 @@ class InferenceVisitor extends BodyVisitor1 { if (!inferrer.isTopLevel) { KernelLibraryBuilder library = inferrer.library; if (inferenceNeeded) { - library.checkBoundsInListLiteral(node, inferrer.typeSchemaEnvironment, + library.checkBoundsInListLiteral( + node, inferrer.typeSchemaEnvironment, inferrer.helper.uri, inferred: true); } } @@ -1475,7 +1476,8 @@ class InferenceVisitor extends BodyVisitor1 { // Either both [_declaredKeyType] and [_declaredValueType] are omitted or // none of them, so we may just check one. if (inferenceNeeded) { - library.checkBoundsInMapLiteral(node, inferrer.typeSchemaEnvironment, + library.checkBoundsInMapLiteral( + node, inferrer.typeSchemaEnvironment, inferrer.helper.uri, inferred: true); } } @@ -1760,7 +1762,8 @@ class InferenceVisitor extends BodyVisitor1 { if (!inferrer.isTopLevel) { KernelLibraryBuilder library = inferrer.library; if (inferenceNeeded) { - library.checkBoundsInSetLiteral(node, inferrer.typeSchemaEnvironment, + library.checkBoundsInSetLiteral( + node, inferrer.typeSchemaEnvironment, inferrer.helper.uri, inferred: true); } @@ -1814,7 +1817,7 @@ class InferenceVisitor extends BodyVisitor1 { inferrer.storeInferredType(node, inferenceResult.type); if (!hadExplicitTypeArguments && node.target != null) { inferrer.library?.checkBoundsInStaticInvocation( - node, inferrer.typeSchemaEnvironment, + node, inferrer.typeSchemaEnvironment, inferrer.helper.uri, inferred: true); } } @@ -2025,7 +2028,7 @@ class InferenceVisitor extends BodyVisitor1 { KernelLibraryBuilder library = inferrer.library; if (node._implicitlyTyped) { library.checkBoundsInVariableDeclaration( - node, inferrer.typeSchemaEnvironment, + node, inferrer.typeSchemaEnvironment, inferrer.helper.uri, inferred: true); } } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart index 5e4ac3aff6a9..b36770c89d54 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart @@ -340,7 +340,8 @@ abstract class KernelClassBuilder } } - library.reportTypeArgumentIssue(message, charOffset, typeParameter); + library.reportTypeArgumentIssue( + message, fileUri, charOffset, typeParameter); } } } @@ -379,7 +380,7 @@ abstract class KernelClassBuilder } library.reportTypeArgumentIssue( - message, parameter.fileOffset, typeParameter); + message, fileUri, parameter.fileOffset, typeParameter); } } } @@ -402,15 +403,17 @@ abstract class KernelClassBuilder library.checkBoundsInField(field, typeEnvironment); } for (Procedure procedure in cls.procedures) { - library.checkBoundsInFunctionNode(procedure.function, typeEnvironment); + library.checkBoundsInFunctionNode( + procedure.function, typeEnvironment, fileUri); } for (Constructor constructor in cls.constructors) { - library.checkBoundsInFunctionNode(constructor.function, typeEnvironment); + library.checkBoundsInFunctionNode( + constructor.function, typeEnvironment, fileUri); } for (RedirectingFactoryConstructor redirecting in cls.redirectingFactoryConstructors) { library.checkBoundsInFunctionNodeParts( - typeEnvironment, redirecting.fileOffset, + typeEnvironment, fileUri, redirecting.fileOffset, typeParameters: redirecting.typeParameters, positionalParameters: redirecting.positionalParameters, namedParameters: redirecting.namedParameters); diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart index 1532c58382ca..91a846a159a7 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart @@ -1481,7 +1481,8 @@ class KernelLibraryBuilder addToExportScope(name, member); } - void reportTypeArgumentIssues(List issues, int offset, + void reportTypeArgumentIssues( + List issues, Uri fileUri, int offset, {bool inferred, DartType targetReceiver, String targetName}) { for (TypeArgumentIssue issue in issues) { DartType argument = issue.argument; @@ -1542,12 +1543,12 @@ class KernelLibraryBuilder } } - reportTypeArgumentIssue(message, offset, typeParameter); + reportTypeArgumentIssue(message, fileUri, offset, typeParameter); } } - void reportTypeArgumentIssue( - Message message, int fileOffset, TypeParameter typeParameter) { + void reportTypeArgumentIssue(Message message, Uri fileUri, int fileOffset, + TypeParameter typeParameter) { List context; if (typeParameter != null && typeParameter.fileOffset != -1) { // It looks like when parameters come from patch files, they don't @@ -1562,12 +1563,13 @@ class KernelLibraryBuilder void checkBoundsInField(Field field, TypeEnvironment typeEnvironment) { if (loader.target.legacyMode) return; - checkBoundsInType(field.type, typeEnvironment, field.fileOffset, + checkBoundsInType( + field.type, typeEnvironment, field.fileUri, field.fileOffset, allowSuperBounded: true); } void checkBoundsInFunctionNodeParts( - TypeEnvironment typeEnvironment, int fileOffset, + TypeEnvironment typeEnvironment, Uri fileUri, int fileOffset, {List typeParameters, List positionalParameters, List namedParameters, @@ -1576,19 +1578,21 @@ class KernelLibraryBuilder if (typeParameters != null) { for (TypeParameter parameter in typeParameters) { checkBoundsInType( - parameter.bound, typeEnvironment, parameter.fileOffset, + parameter.bound, typeEnvironment, fileUri, parameter.fileOffset, allowSuperBounded: true); } } if (positionalParameters != null) { for (VariableDeclaration formal in positionalParameters) { - checkBoundsInType(formal.type, typeEnvironment, formal.fileOffset, + checkBoundsInType( + formal.type, typeEnvironment, fileUri, formal.fileOffset, allowSuperBounded: true); } } if (namedParameters != null) { for (VariableDeclaration named in namedParameters) { - checkBoundsInType(named.type, typeEnvironment, named.fileOffset, + checkBoundsInType( + named.type, typeEnvironment, fileUri, named.fileOffset, allowSuperBounded: true); } } @@ -1617,16 +1621,17 @@ class KernelLibraryBuilder getGenericTypeName(issue.enclosingType)); } - reportTypeArgumentIssue(message, offset, typeParameter); + reportTypeArgumentIssue(message, fileUri, offset, typeParameter); } } } } void checkBoundsInFunctionNode( - FunctionNode function, TypeEnvironment typeEnvironment) { + FunctionNode function, TypeEnvironment typeEnvironment, Uri fileUri) { if (loader.target.legacyMode) return; - checkBoundsInFunctionNodeParts(typeEnvironment, function.fileOffset, + checkBoundsInFunctionNodeParts( + typeEnvironment, fileUri, function.fileOffset, typeParameters: function.typeParameters, positionalParameters: function.positionalParameters, namedParameters: function.namedParameters, @@ -1634,64 +1639,69 @@ class KernelLibraryBuilder } void checkBoundsInListLiteral( - ListLiteral node, TypeEnvironment typeEnvironment, + ListLiteral node, TypeEnvironment typeEnvironment, Uri fileUri, {bool inferred = false}) { if (loader.target.legacyMode) return; - checkBoundsInType(node.typeArgument, typeEnvironment, node.fileOffset, + checkBoundsInType( + node.typeArgument, typeEnvironment, fileUri, node.fileOffset, inferred: inferred, allowSuperBounded: true); } - void checkBoundsInSetLiteral(SetLiteral node, TypeEnvironment typeEnvironment, + void checkBoundsInSetLiteral( + SetLiteral node, TypeEnvironment typeEnvironment, Uri fileUri, {bool inferred = false}) { if (loader.target.legacyMode) return; - checkBoundsInType(node.typeArgument, typeEnvironment, node.fileOffset, + checkBoundsInType( + node.typeArgument, typeEnvironment, fileUri, node.fileOffset, inferred: inferred, allowSuperBounded: true); } - void checkBoundsInMapLiteral(MapLiteral node, TypeEnvironment typeEnvironment, + void checkBoundsInMapLiteral( + MapLiteral node, TypeEnvironment typeEnvironment, Uri fileUri, {bool inferred = false}) { if (loader.target.legacyMode) return; - checkBoundsInType(node.keyType, typeEnvironment, node.fileOffset, + checkBoundsInType(node.keyType, typeEnvironment, fileUri, node.fileOffset, inferred: inferred, allowSuperBounded: true); - checkBoundsInType(node.valueType, typeEnvironment, node.fileOffset, + checkBoundsInType(node.valueType, typeEnvironment, fileUri, node.fileOffset, inferred: inferred, allowSuperBounded: true); } void checkBoundsInType( - DartType type, TypeEnvironment typeEnvironment, int offset, + DartType type, TypeEnvironment typeEnvironment, Uri fileUri, int offset, {bool inferred, bool allowSuperBounded = true}) { if (loader.target.legacyMode) return; List issues = findTypeArgumentIssues( type, typeEnvironment, allowSuperBounded: allowSuperBounded); if (issues != null) { - reportTypeArgumentIssues(issues, offset, inferred: inferred); + reportTypeArgumentIssues(issues, fileUri, offset, inferred: inferred); } } void checkBoundsInVariableDeclaration( - VariableDeclaration node, TypeEnvironment typeEnvironment, + VariableDeclaration node, TypeEnvironment typeEnvironment, Uri fileUri, {bool inferred = false}) { if (loader.target.legacyMode) return; if (node.type == null) return; - checkBoundsInType(node.type, typeEnvironment, node.fileOffset, + checkBoundsInType(node.type, typeEnvironment, fileUri, node.fileOffset, inferred: inferred, allowSuperBounded: true); } void checkBoundsInConstructorInvocation( - ConstructorInvocation node, TypeEnvironment typeEnvironment, + ConstructorInvocation node, TypeEnvironment typeEnvironment, Uri fileUri, {bool inferred = false}) { if (loader.target.legacyMode) return; if (node.arguments.types.isEmpty) return; Constructor constructor = node.target; Class klass = constructor.enclosingClass; DartType constructedType = new InterfaceType(klass, node.arguments.types); - checkBoundsInType(constructedType, typeEnvironment, node.fileOffset, + checkBoundsInType( + constructedType, typeEnvironment, fileUri, node.fileOffset, inferred: inferred, allowSuperBounded: false); } void checkBoundsInFactoryInvocation( - StaticInvocation node, TypeEnvironment typeEnvironment, + StaticInvocation node, TypeEnvironment typeEnvironment, Uri fileUri, {bool inferred = false}) { if (loader.target.legacyMode) return; if (node.arguments.types.isEmpty) return; @@ -1699,12 +1709,13 @@ class KernelLibraryBuilder assert(factory.isFactory); Class klass = factory.enclosingClass; DartType constructedType = new InterfaceType(klass, node.arguments.types); - checkBoundsInType(constructedType, typeEnvironment, node.fileOffset, + checkBoundsInType( + constructedType, typeEnvironment, fileUri, node.fileOffset, inferred: inferred, allowSuperBounded: false); } void checkBoundsInStaticInvocation( - StaticInvocation node, TypeEnvironment typeEnvironment, + StaticInvocation node, TypeEnvironment typeEnvironment, Uri fileUri, {bool inferred = false}) { if (loader.target.legacyMode) return; if (node.arguments.types.isEmpty) return; @@ -1721,7 +1732,7 @@ class KernelLibraryBuilder targetReceiver = new InterfaceType(klass); } String targetName = node.target.name.name; - reportTypeArgumentIssues(issues, node.fileOffset, + reportTypeArgumentIssues(issues, fileUri, node.fileOffset, inferred: inferred, targetReceiver: targetReceiver, targetName: targetName); @@ -1736,6 +1747,7 @@ class KernelLibraryBuilder Name name, Member interfaceTarget, Arguments arguments, + Uri fileUri, int offset, {bool inferred = false}) { if (loader.target.legacyMode) return; @@ -1781,7 +1793,7 @@ class KernelLibraryBuilder List issues = findTypeArgumentIssuesForInvocation( instantiatedMethodParameters, arguments.types, typeEnvironment); if (issues != null) { - reportTypeArgumentIssues(issues, offset, + reportTypeArgumentIssues(issues, fileUri, offset, inferred: inferred, targetReceiver: receiverType, targetName: name.name); @@ -1796,7 +1808,8 @@ class KernelLibraryBuilder if (declaration is KernelFieldBuilder) { checkBoundsInField(declaration.target, typeEnvironment); } else if (declaration is KernelProcedureBuilder) { - checkBoundsInFunctionNode(declaration.target.function, typeEnvironment); + checkBoundsInFunctionNode( + declaration.target.function, typeEnvironment, declaration.fileUri); } else if (declaration is KernelClassBuilder) { declaration.checkBoundsInOutline(typeEnvironment); } diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart index 05052a688f54..bbe689972193 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart @@ -1611,6 +1611,7 @@ abstract class TypeInferrerImpl extends TypeInferrer { actualMethodName, interfaceTarget, arguments, + helper.uri, fileOffset, inferred: getExplicitTypeArguments(arguments) == null); } @@ -1957,9 +1958,9 @@ abstract class MixinInferrer { mixinSuperclass.implementedTypes.length != 2)) { unexpected( 'Compiler-generated mixin applications have a mixin or else ' - 'implement exactly one type', + 'implement exactly one type', '$mixinSuperclass implements ' - '${mixinSuperclass.implementedTypes.length} types', + '${mixinSuperclass.implementedTypes.length} types', mixinSuperclass.fileOffset, mixinSuperclass.fileUri); } diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status index 415b5dc41cf4..65cb2ec213e6 100644 --- a/pkg/front_end/messages.status +++ b/pkg/front_end/messages.status @@ -3,17 +3,6 @@ # BSD-style license that can be found in the LICENSE.md file. # Not sorted --- these crashes should be fixed ASAP! -GenericFunctionTypeInferredAsActualTypeArgument/part_wrapped_script: Crash -GenericFunctionTypeUsedAsActualTypeArgument/part_wrapped_script1: Crash -GenericFunctionTypeUsedAsActualTypeArgument/part_wrapped_script2: Crash -IncorrectTypeArgument/part_wrapped_script: Crash -IncorrectTypeArgumentInReturnType/part_wrapped_script: Crash -IncorrectTypeArgumentInSupertype/part_wrapped_script: Crash -IncorrectTypeArgumentInSupertypeInferred/part_wrapped_script: Crash -IncorrectTypeArgumentInferred/part_wrapped_script: Crash -IncorrectTypeArgumentQualified/part_wrapped_script: Crash -IncorrectTypeArgumentQualifiedInferred/part_wrapped_script: Crash -IntersectionTypeAsTypeArgument/part_wrapped_script: Crash PartTwice/part_wrapped_script: Crash AbstractClassInstantiation/example: Fail