mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:19:49 +00:00
Fix resynthesis for 'dynamic op value' constant expressions.
1. Move error checking before. 2. Remove check for operator using resolution, because there is no resolution for dynamic target. _toBinaryOperatorTokenType() will throw if the operatorName is not actually the name of an operator. R=brianwilkerson@google.com, paulberry@google.com Bug: Change-Id: Iaa7d909ec8a6c13f306fd73122a10a0de170e7e1 Reviewed-on: https://dart-review.googlesource.com/29181 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
24a510a91e
commit
88575a3f4c
|
@ -488,6 +488,7 @@ class _ExprBuilder {
|
|||
if (expr is kernel.StringLiteral) {
|
||||
return AstTestFactory.string2(expr.value);
|
||||
}
|
||||
|
||||
if (expr is kernel.StringConcatenation) {
|
||||
List<InterpolationElement> elements = expr.expressions
|
||||
.map(_build)
|
||||
|
@ -495,6 +496,7 @@ class _ExprBuilder {
|
|||
.toList(growable: false);
|
||||
return AstTestFactory.string(elements);
|
||||
}
|
||||
|
||||
if (expr is kernel.SymbolLiteral) {
|
||||
List<String> components = expr.value.split('.').toList();
|
||||
return AstTestFactory.symbolLiteral(components);
|
||||
|
@ -524,6 +526,20 @@ class _ExprBuilder {
|
|||
return AstTestFactory.mapLiteral(keyword, typeArguments, entries);
|
||||
}
|
||||
|
||||
// Invalid annotations are represented as Let.
|
||||
if (expr is kernel.Let) {
|
||||
kernel.Let let = expr;
|
||||
if (_isConstantExpressionErrorThrow(let.variable.initializer) ||
|
||||
_isConstantExpressionErrorThrow(let.body)) {
|
||||
throw const _CompilationErrorFound();
|
||||
}
|
||||
}
|
||||
|
||||
// Stop if there is an error.
|
||||
if (_isConstantExpressionErrorThrow(expr)) {
|
||||
throw const _CompilationErrorFound();
|
||||
}
|
||||
|
||||
if (expr is kernel.StaticGet) {
|
||||
return _buildIdentifier(expr.targetReference, isGet: true);
|
||||
}
|
||||
|
@ -572,6 +588,10 @@ class _ExprBuilder {
|
|||
return AstTestFactory.binaryExpression(left, operator, right);
|
||||
}
|
||||
|
||||
if (expr is kernel.AsExpression && expr.isTypeError) {
|
||||
return _build(expr.operand);
|
||||
}
|
||||
|
||||
if (expr is kernel.Let) {
|
||||
var body = expr.body;
|
||||
if (body is kernel.ConditionalExpression) {
|
||||
|
@ -595,25 +615,20 @@ class _ExprBuilder {
|
|||
}
|
||||
|
||||
if (expr is kernel.MethodInvocation) {
|
||||
kernel.Member member = expr.interfaceTarget;
|
||||
if (member is kernel.Procedure) {
|
||||
if (member.kind == kernel.ProcedureKind.Operator) {
|
||||
var left = _build(expr.receiver);
|
||||
String operatorName = expr.name.name;
|
||||
List<kernel.Expression> args = expr.arguments.positional;
|
||||
if (args.isEmpty) {
|
||||
if (operatorName == 'unary-') {
|
||||
return AstTestFactory.prefixExpression(TokenType.MINUS, left);
|
||||
}
|
||||
if (operatorName == '~') {
|
||||
return AstTestFactory.prefixExpression(TokenType.TILDE, left);
|
||||
}
|
||||
} else if (args.length == 1) {
|
||||
var operator = _toBinaryOperatorTokenType(operatorName);
|
||||
var right = _build(args.single);
|
||||
return AstTestFactory.binaryExpression(left, operator, right);
|
||||
}
|
||||
var left = _build(expr.receiver);
|
||||
String operatorName = expr.name.name;
|
||||
List<kernel.Expression> args = expr.arguments.positional;
|
||||
if (args.isEmpty) {
|
||||
if (operatorName == 'unary-') {
|
||||
return AstTestFactory.prefixExpression(TokenType.MINUS, left);
|
||||
}
|
||||
if (operatorName == '~') {
|
||||
return AstTestFactory.prefixExpression(TokenType.TILDE, left);
|
||||
}
|
||||
} else if (args.length == 1) {
|
||||
var operator = _toBinaryOperatorTokenType(operatorName);
|
||||
var right = _build(args.single);
|
||||
return AstTestFactory.binaryExpression(left, operator, right);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -660,20 +675,6 @@ class _ExprBuilder {
|
|||
return identifier;
|
||||
}
|
||||
|
||||
// Invalid annotations are represented as Let.
|
||||
if (expr is kernel.Let) {
|
||||
kernel.Let let = expr;
|
||||
if (_isConstantExpressionErrorThrow(let.variable.initializer) ||
|
||||
_isConstantExpressionErrorThrow(let.body)) {
|
||||
throw const _CompilationErrorFound();
|
||||
}
|
||||
}
|
||||
|
||||
// Stop if there is an error.
|
||||
if (_isConstantExpressionErrorThrow(expr)) {
|
||||
throw const _CompilationErrorFound();
|
||||
}
|
||||
|
||||
// TODO(scheglov): complete getExpression
|
||||
throw new UnimplementedError('kernel: (${expr.runtimeType}) $expr');
|
||||
}
|
||||
|
|
|
@ -347,13 +347,6 @@ class NonErrorResolverTest_Kernel extends NonErrorResolverTest_Driver {
|
|||
return super.test_nonConstMapKey_constField();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
test_nonConstValueInInitializer_binary_dynamic() async {
|
||||
return super.test_nonConstValueInInitializer_binary_dynamic();
|
||||
}
|
||||
|
||||
@override
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
|
|
|
@ -85,13 +85,6 @@ class AnalysisDriverTest_Kernel extends AnalysisDriverTest {
|
|||
await super.test_const_annotation_withArgs();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
test_const_circular_reference() async {
|
||||
await super.test_const_circular_reference();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
@potentialAnalyzerProblem
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue