Skip to content

Commit

Permalink
Store resolution for out of range integer literals.
Browse files Browse the repository at this point in the history
R=brianwilkerson@google.com

Change-Id: Ice783c3fc279bfd34a5aeebf4e9e9f5f014c000b
Reviewed-on: https://dart-review.googlesource.com/68423
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Aug 3, 2018
1 parent bfa890d commit 8df84c0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -560,18 +560,6 @@ class CompileTimeErrorCodeTest_Kernel extends CompileTimeErrorCodeTest_Driver {
await super.test_instantiateEnum_new();
}

@override
@failingTest
test_integerLiteralOutOfRange_negative() async {
await super.test_integerLiteralOutOfRange_negative();
}

@override
@failingTest
test_integerLiteralOutOfRange_positive() async {
await super.test_integerLiteralOutOfRange_positive();
}

@override
@failingTest
test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() {
Expand Down
5 changes: 3 additions & 2 deletions pkg/front_end/lib/src/fasta/kernel/fangorn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ class Fangorn extends Forest {
}

@override
IntJudgment literalInt(int value, Token token) {
IntJudgment literalInt(int value, Token token, {Expression desugaredError}) {
return new IntJudgment(
typeInferenceTokensSaver?.intLiteralTokens(token), value)
typeInferenceTokensSaver?.intLiteralTokens(token), value,
desugaredError: desugaredError)
..fileOffset = offsetForToken(token);
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/fasta/kernel/forest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract class Forest {

/// Return a representation of an integer literal at the given [location]. The
/// literal has the given [value].
Expression literalInt(int value, Token location);
Expression literalInt(int value, Token location, {Expression desugaredError});

/// Return a representation of a list literal. The [constKeyword] is the
/// location of the `const` keyword, or `null` if there is no keyword. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1427,23 +1427,30 @@ class KernelLargeIntAccessGenerator extends KernelGenerator
: super(helper, token);

@override
Expression _makeSimpleRead() => new SyntheticExpressionJudgment(buildError());
Expression _makeSimpleRead() {
return _buildErrorIntLiteral();
}

@override
Expression _makeSimpleWrite(Expression value, bool voidContext,
ComplexAssignmentJudgment complexAssignment) {
return new SyntheticExpressionJudgment(buildError());
return _buildErrorIntLiteral();
}

@override
Expression _makeRead(ComplexAssignmentJudgment complexAssignment) {
return new SyntheticExpressionJudgment(buildError());
return _buildErrorIntLiteral();
}

@override
Expression _makeWrite(Expression value, bool voidContext,
ComplexAssignmentJudgment complexAssignment) {
return new SyntheticExpressionJudgment(buildError());
return _buildErrorIntLiteral();
}

Expression _buildErrorIntLiteral() {
var error = buildError();
return forest.literalInt(0, token, desugaredError: error);
}
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1597,16 +1597,21 @@ abstract class InitializerJudgment implements Initializer {
/// Concrete shadow object representing an integer literal in kernel form.
class IntJudgment extends IntLiteral implements ExpressionJudgment {
IntLiteralTokens tokens;
final kernel.Expression desugaredError;

DartType inferredType;

IntJudgment(this.tokens, int value) : super(value);
IntJudgment(this.tokens, int value, {this.desugaredError}) : super(value);

@override
Expression infer<Expression, Statement, Initializer, Type>(
ShadowTypeInferrer inferrer, DartType typeContext) {
inferredType = inferrer.coreTypes.intClass.rawType;
inferrer.listener.intLiteral(this, fileOffset, tokens, value, inferredType);
if (desugaredError != null) {
parent.replaceChild(this, desugaredError);
parent = null;
}
return null;
}
}
Expand Down

0 comments on commit 8df84c0

Please sign in to comment.