Issue 50502. Fix a couple of analyzer unit tests.
Bug: https://github.com/dart-lang/sdk/issues/50502 Change-Id: I1299a4fadaffae9b319ca0db1d2629a27a4775b7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285702 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Queue
parent
854dc20416
commit
a4687a0e2b
@@ -599,21 +599,50 @@ AssignmentExpression
|
||||
}
|
||||
|
||||
test_notLValue_parenthesized_simple() async {
|
||||
// TODO(paulberry): remove `// @dart = 2.18` - see
|
||||
// https://github.com/dart-lang/sdk/issues/50502
|
||||
await assertErrorsInCode(r'''
|
||||
// @dart = 2.18
|
||||
void f(int a, int b, double c) {
|
||||
(a + b) = c;
|
||||
void f(int a, double b) {
|
||||
(a + 0) = b;
|
||||
}
|
||||
''', [
|
||||
error(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, 51, 7),
|
||||
error(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, 51, 7),
|
||||
error(CompileTimeErrorCode.PATTERN_TYPE_MISMATCH_IN_IRREFUTABLE_CONTEXT,
|
||||
29, 1),
|
||||
error(ParserErrorCode.EXPECTED_TOKEN, 31, 1),
|
||||
]);
|
||||
|
||||
var assignment = findNode.assignment('= c');
|
||||
var node = findNode.singlePatternAssignment;
|
||||
assertResolvedNodeText(node, r'''
|
||||
PatternAssignment
|
||||
pattern: ParenthesizedPattern
|
||||
leftParenthesis: (
|
||||
pattern: AssignedVariablePattern
|
||||
name: a
|
||||
element: self::@function::f::@parameter::a
|
||||
matchedValueType: double
|
||||
rightParenthesis: )
|
||||
matchedValueType: double
|
||||
equals: =
|
||||
expression: SimpleIdentifier
|
||||
token: b
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: double
|
||||
patternTypeSchema: int
|
||||
staticType: double
|
||||
''');
|
||||
}
|
||||
|
||||
assertResolvedNodeText(assignment, r'''
|
||||
test_notLValue_parenthesized_simple_language219() async {
|
||||
await assertErrorsInCode(r'''
|
||||
// @dart = 2.19
|
||||
void f(int a, double b) {
|
||||
(a + 0) = b;
|
||||
}
|
||||
''', [
|
||||
error(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, 44, 7),
|
||||
error(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, 44, 7),
|
||||
]);
|
||||
|
||||
var node = findNode.assignment('= b');
|
||||
assertResolvedNodeText(node, r'''
|
||||
AssignmentExpression
|
||||
leftHandSide: ParenthesizedExpression
|
||||
leftParenthesis: (
|
||||
@@ -623,10 +652,9 @@ AssignmentExpression
|
||||
staticElement: self::@function::f::@parameter::a
|
||||
staticType: int
|
||||
operator: +
|
||||
rightOperand: SimpleIdentifier
|
||||
token: b
|
||||
rightOperand: IntegerLiteral
|
||||
literal: 0
|
||||
parameter: dart:core::@class::num::@method::+::@parameter::other
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: int
|
||||
staticElement: dart:core::@class::num::@method::+
|
||||
staticInvokeType: num Function(num)
|
||||
@@ -635,9 +663,9 @@ AssignmentExpression
|
||||
staticType: int
|
||||
operator: =
|
||||
rightHandSide: SimpleIdentifier
|
||||
token: c
|
||||
token: b
|
||||
parameter: <null>
|
||||
staticElement: self::@function::f::@parameter::c
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: double
|
||||
readElement: <null>
|
||||
readType: null
|
||||
|
||||
@@ -289,7 +289,6 @@ var y = {null: null};
|
||||
assertType(yElement.type, 'Map<Null, Null>');
|
||||
}
|
||||
|
||||
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/50502')
|
||||
test_switchExpression_asContext_forCases() async {
|
||||
var code = r'''
|
||||
class C<T> {
|
||||
@@ -305,7 +304,7 @@ void test(C<int> x) {
|
||||
}
|
||||
}''';
|
||||
await resolveTestCode(code);
|
||||
var node = findNode.instanceCreation('const C():');
|
||||
var node = findNode.instanceCreation('C():');
|
||||
assertType(node, 'C<int>');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user