Skip to content

Commit

Permalink
[cfe] Pass fileUri to more things when issuing problems
Browse files Browse the repository at this point in the history
The library builders uri might not be correct as the problems can
originate in parts.

Fixes #36990

Change-Id: I1c39a31052b88013df38033a49b662ce5bb86aad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106083
Commit-Queue: Jens Johansen <[email protected]>
Reviewed-by: Dmitry Stefantsov <[email protected]>
  • Loading branch information
jensjoha authored and [email protected] committed Jun 19, 2019
1 parent 1aa8959 commit c6426e1
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 65 deletions.
19 changes: 10 additions & 9 deletions pkg/front_end/lib/src/fasta/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
isConst: isConst)
..fileOffset = identifier.charOffset
..fileEqualsOffset = offsetForToken(equalsToken);
library.checkBoundsInVariableDeclaration(variable, typeEnvironment);
library.checkBoundsInVariableDeclaration(variable, typeEnvironment, uri);
push(variable);
}

Expand Down Expand Up @@ -2464,7 +2464,7 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
leftBracket,
expressions,
rightBracket);
library.checkBoundsInListLiteral(node, typeEnvironment);
library.checkBoundsInListLiteral(node, typeEnvironment, uri);
push(node);
}

Expand Down Expand Up @@ -2503,7 +2503,7 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
leftBrace,
expressions,
leftBrace.endGroup);
library.checkBoundsInSetLiteral(node, typeEnvironment);
library.checkBoundsInSetLiteral(node, typeEnvironment, uri);
if (!library.loader.target.enableSetLiterals) {
internalProblem(
fasta.messageSetLiteralsNotSupported, node.fileOffset, uri);
Expand Down Expand Up @@ -2627,7 +2627,7 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
leftBrace,
entries,
leftBrace.endGroup);
library.checkBoundsInMapLiteral(node, typeEnvironment);
library.checkBoundsInMapLiteral(node, typeEnvironment, uri);
push(node);
}

Expand Down Expand Up @@ -2793,7 +2793,7 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
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) {
Expand All @@ -2815,7 +2815,8 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
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);
Expand Down Expand Up @@ -3372,7 +3373,7 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
target, forest.castArguments(arguments),
isConst: isConst)
..fileOffset = charOffset;
library.checkBoundsInConstructorInvocation(node, typeEnvironment);
library.checkBoundsInConstructorInvocation(node, typeEnvironment, uri);
return node;
} else {
Procedure procedure = target;
Expand All @@ -3392,14 +3393,14 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
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;
}
}
Expand Down
17 changes: 10 additions & 7 deletions pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class InferenceVisitor extends BodyVisitor1<void, DartType> {
KernelLibraryBuilder library = inferrer.library;
if (!hasExplicitTypeArguments) {
library.checkBoundsInConstructorInvocation(
node, inferrer.typeSchemaEnvironment,
node, inferrer.typeSchemaEnvironment, inferrer.helper.uri,
inferred: true);
}
}
Expand Down Expand Up @@ -244,7 +244,7 @@ class InferenceVisitor extends BodyVisitor1<void, DartType> {
KernelLibraryBuilder library = inferrer.library;
if (!hadExplicitTypeArguments) {
library.checkBoundsInFactoryInvocation(
node, inferrer.typeSchemaEnvironment,
node, inferrer.typeSchemaEnvironment, inferrer.helper.uri,
inferred: true);
}
}
Expand Down Expand Up @@ -919,7 +919,8 @@ class InferenceVisitor extends BodyVisitor1<void, DartType> {
if (!inferrer.isTopLevel) {
KernelLibraryBuilder library = inferrer.library;
if (inferenceNeeded) {
library.checkBoundsInListLiteral(node, inferrer.typeSchemaEnvironment,
library.checkBoundsInListLiteral(
node, inferrer.typeSchemaEnvironment, inferrer.helper.uri,
inferred: true);
}
}
Expand Down Expand Up @@ -1475,7 +1476,8 @@ class InferenceVisitor extends BodyVisitor1<void, DartType> {
// 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);
}
}
Expand Down Expand Up @@ -1760,7 +1762,8 @@ class InferenceVisitor extends BodyVisitor1<void, DartType> {
if (!inferrer.isTopLevel) {
KernelLibraryBuilder library = inferrer.library;
if (inferenceNeeded) {
library.checkBoundsInSetLiteral(node, inferrer.typeSchemaEnvironment,
library.checkBoundsInSetLiteral(
node, inferrer.typeSchemaEnvironment, inferrer.helper.uri,
inferred: true);
}

Expand Down Expand Up @@ -1814,7 +1817,7 @@ class InferenceVisitor extends BodyVisitor1<void, DartType> {
inferrer.storeInferredType(node, inferenceResult.type);
if (!hadExplicitTypeArguments && node.target != null) {
inferrer.library?.checkBoundsInStaticInvocation(
node, inferrer.typeSchemaEnvironment,
node, inferrer.typeSchemaEnvironment, inferrer.helper.uri,
inferred: true);
}
}
Expand Down Expand Up @@ -2025,7 +2028,7 @@ class InferenceVisitor extends BodyVisitor1<void, DartType> {
KernelLibraryBuilder library = inferrer.library;
if (node._implicitlyTyped) {
library.checkBoundsInVariableDeclaration(
node, inferrer.typeSchemaEnvironment,
node, inferrer.typeSchemaEnvironment, inferrer.helper.uri,
inferred: true);
}
}
Expand Down
13 changes: 8 additions & 5 deletions pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ abstract class KernelClassBuilder
}
}

library.reportTypeArgumentIssue(message, charOffset, typeParameter);
library.reportTypeArgumentIssue(
message, fileUri, charOffset, typeParameter);
}
}
}
Expand Down Expand Up @@ -379,7 +380,7 @@ abstract class KernelClassBuilder
}

library.reportTypeArgumentIssue(
message, parameter.fileOffset, typeParameter);
message, fileUri, parameter.fileOffset, typeParameter);
}
}
}
Expand All @@ -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);
Expand Down
Loading

0 comments on commit c6426e1

Please sign in to comment.