CQ. Migrate resolution tests to resolveTestCodeWithDiagnostics. AB.
Change-Id: I7aaed1e340ab7a3086f1b5ca78019b811e06c56e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503720 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
98c3699f32
commit
7b4ca03c82
@@ -5,17 +5,19 @@
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_collection_resolution.dart';
|
||||
import 'node_text_expectations.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(AdjacentStringsResolutionTest);
|
||||
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class AdjacentStringsResolutionTest extends PubPackageResolutionTest {
|
||||
test_it() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
void f() {
|
||||
'aaa' 'bbb' 'ccc';
|
||||
}
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_collection_resolution.dart';
|
||||
import 'node_text_expectations.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(AsExpressionResolutionTest);
|
||||
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class AsExpressionResolutionTest extends PubPackageResolutionTest {
|
||||
test_expression_constVariable() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
const num a = 1.2;
|
||||
const int b = a as int;
|
||||
''',
|
||||
[error(diag.constEvalThrowsException, 33, 8)],
|
||||
);
|
||||
// ^^^^^^^^
|
||||
// [diag.constEvalThrowsException] Evaluation of this constant expression throws an exception.
|
||||
''');
|
||||
|
||||
var node = findNode.asExpression('as int');
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -41,7 +41,7 @@ AsExpression
|
||||
}
|
||||
|
||||
test_expression_localVariable() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
void f() {
|
||||
num v = 42;
|
||||
v as int;
|
||||
@@ -65,16 +65,15 @@ AsExpression
|
||||
}
|
||||
|
||||
test_expression_super() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A<T> {
|
||||
void f() {
|
||||
super as T;
|
||||
// ^^^^^
|
||||
// [diag.missingAssignableSelector] Missing selector such as '.identifier' or '[0]'.
|
||||
}
|
||||
}
|
||||
''',
|
||||
[error(diag.missingAssignableSelector, 30, 5)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.singleAsExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -92,7 +91,7 @@ AsExpression
|
||||
}
|
||||
|
||||
test_expression_switchExpression() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
void f(Object? x) {
|
||||
(switch (x) {
|
||||
_ => 0,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,17 +2,18 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_collection_resolution.dart';
|
||||
import 'node_text_expectations.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(AstRewriteImplicitCallReferenceTest);
|
||||
defineReflectiveTests(AstRewriteMethodInvocationTest);
|
||||
defineReflectiveTests(AstRewritePrefixedIdentifierTest);
|
||||
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||
|
||||
// TODO(srawlins): Add AstRewriteInstanceCreationExpressionTest test, likely
|
||||
// moving many test cases from ConstructorReferenceResolutionTest,
|
||||
@@ -26,7 +27,7 @@ main() {
|
||||
@reflectiveTest
|
||||
class AstRewriteImplicitCallReferenceTest extends PubPackageResolutionTest {
|
||||
test_assignment_indexExpression() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -78,7 +79,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_conditional_else() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class A {}
|
||||
abstract class C extends A {
|
||||
void call();
|
||||
@@ -110,7 +111,7 @@ ConditionalExpression
|
||||
}
|
||||
|
||||
test_conditional_then() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class A {}
|
||||
abstract class C extends A {
|
||||
void call();
|
||||
@@ -142,7 +143,7 @@ ConditionalExpression
|
||||
}
|
||||
|
||||
test_explicitTypeArguments() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class C {
|
||||
T call<T>(T t) => t;
|
||||
}
|
||||
@@ -176,20 +177,18 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_ifNull_lhs() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class A {}
|
||||
abstract class C extends A {
|
||||
void call();
|
||||
}
|
||||
|
||||
void Function() f(A a, bool b, C c, dynamic d) => b ? d : c ?? a;
|
||||
''',
|
||||
[
|
||||
error(diag.deadCode, 127, 4),
|
||||
error(diag.deadNullAwareExpression, 130, 1),
|
||||
],
|
||||
);
|
||||
// ^^^^
|
||||
// [diag.deadCode] Dead code.
|
||||
// ^
|
||||
// [diag.deadNullAwareExpression] The left operand can't be null, so the right operand is never executed.
|
||||
''');
|
||||
// `c` is on the LHS of an if-null expression, so implicit call tearoff
|
||||
// logic should not apply to it.
|
||||
// Therefore the type of `c ?? a` should be `A`.
|
||||
@@ -213,7 +212,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_ifNull_rhs() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -246,7 +245,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_listLiteral_element() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -269,7 +268,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_listLiteral_forElement() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -294,7 +293,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_listLiteral_ifElement() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -319,7 +318,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_listLiteral_ifElement_else() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -345,7 +344,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_parenthesized_cascade_target() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call();
|
||||
void m();
|
||||
@@ -384,7 +383,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_prefixedIdentifier() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
C get c;
|
||||
void call(int t) => t;
|
||||
@@ -416,7 +415,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_propertyAccess() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
C get c;
|
||||
void call(int t) => t;
|
||||
@@ -455,7 +454,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_setOrMapLiteral_element() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -478,7 +477,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_setOrMapLiteral_mapLiteralEntry_key() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -501,7 +500,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_setOrMapLiteral_mapLiteralEntry_value() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -524,7 +523,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_simpleIdentifier() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class C {
|
||||
void call(int t) => t;
|
||||
}
|
||||
@@ -547,7 +546,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_simpleIdentifier_typeAlias() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {
|
||||
void call() {}
|
||||
}
|
||||
@@ -569,7 +568,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_simpleIdentifier_typeVariable() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {
|
||||
void call() {}
|
||||
}
|
||||
@@ -589,7 +588,7 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_simpleIdentifier_typeVariable2() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {
|
||||
void call() {}
|
||||
}
|
||||
@@ -609,15 +608,14 @@ ImplicitCallReference
|
||||
}
|
||||
|
||||
test_simpleIdentifier_typeVariable2_nullable() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {
|
||||
void call() {}
|
||||
}
|
||||
Function f<X extends A, Y extends X?>(Y y) => y;
|
||||
''',
|
||||
[error(diag.returnOfInvalidTypeFromFunction, 75, 1)],
|
||||
);
|
||||
// ^
|
||||
// [diag.returnOfInvalidTypeFromFunction] A value of type 'Y' can't be returned from the function 'f' because it has a return type of 'Function'.
|
||||
''');
|
||||
|
||||
// Verify that no ImplicitCallReference was inserted.
|
||||
var node = findNode.expressionFunctionBody('y;').expression;
|
||||
@@ -630,15 +628,14 @@ SimpleIdentifier
|
||||
}
|
||||
|
||||
test_simpleIdentifier_typeVariable_nullable() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {
|
||||
void call() {}
|
||||
}
|
||||
Function f<X extends A>(X? x) => x;
|
||||
''',
|
||||
[error(diag.returnOfInvalidTypeFromFunction, 62, 1)],
|
||||
);
|
||||
// ^
|
||||
// [diag.returnOfInvalidTypeFromFunction] A value of type 'X?' can't be returned from the function 'f' because it has a return type of 'Function'.
|
||||
''');
|
||||
|
||||
// Verify that no ImplicitCallReference was inserted.
|
||||
var node = findNode.expressionFunctionBody('x;').expression;
|
||||
@@ -657,7 +654,7 @@ class AstRewriteMethodInvocationTest extends PubPackageResolutionTest
|
||||
|
||||
mixin AstRewriteMethodInvocationTestCases on PubPackageResolutionTest {
|
||||
test_targetNull_cascade() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {
|
||||
void foo() {}
|
||||
}
|
||||
@@ -684,7 +681,7 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_targetNull_class() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A<T, U> {
|
||||
A(int a);
|
||||
}
|
||||
@@ -732,7 +729,7 @@ InstanceCreationExpression
|
||||
}
|
||||
|
||||
test_targetNull_extension() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {}
|
||||
|
||||
extension E<T> on A {
|
||||
@@ -743,7 +740,6 @@ f(A a) {
|
||||
E<int>(a).foo();
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.extensionOverride('E<int>(a)');
|
||||
assertResolvedNodeText(node, r'''
|
||||
ExtensionOverride
|
||||
@@ -774,14 +770,13 @@ ExtensionOverride
|
||||
}
|
||||
|
||||
test_targetNull_function() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void A<T, U>(int a) {}
|
||||
|
||||
f() {
|
||||
A<int, String>(0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('A<int, String>(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -820,7 +815,7 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_targetNull_typeAlias_interfaceType() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A<T, U> {
|
||||
A(int _);
|
||||
}
|
||||
@@ -831,7 +826,6 @@ void f() {
|
||||
X<int, String>(0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.instanceCreation('X<int, String>(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
InstanceCreationExpression
|
||||
@@ -870,17 +864,15 @@ InstanceCreationExpression
|
||||
}
|
||||
|
||||
test_targetNull_typeAlias_Never() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
typedef X = Never;
|
||||
|
||||
void f() {
|
||||
X(0);
|
||||
//^
|
||||
// [diag.invocationOfNonFunction] 'X' isn't a function.
|
||||
}
|
||||
''',
|
||||
[error(diag.invocationOfNonFunction, 33, 1)],
|
||||
);
|
||||
|
||||
''');
|
||||
// Not rewritten.
|
||||
findNode.methodInvocation('X(0)');
|
||||
}
|
||||
@@ -892,14 +884,13 @@ class A<T> {
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
f() {
|
||||
prefix.A.named(0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.instanceCreation('A.named(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
InstanceCreationExpression
|
||||
@@ -943,24 +934,15 @@ class A<T> {
|
||||
}
|
||||
''');
|
||||
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
f() {
|
||||
prefix.A.named<int>(0);
|
||||
// ^^^^^
|
||||
// [diag.wrongNumberOfTypeArgumentsConstructor] The constructor 'prefix.A.named' doesn't have type parameters.
|
||||
}
|
||||
''',
|
||||
[
|
||||
error(
|
||||
diag.wrongNumberOfTypeArgumentsConstructor,
|
||||
50,
|
||||
5,
|
||||
messageContains: ["The constructor 'prefix.A.named'"],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
''');
|
||||
var node = findNode.instanceCreation('named<int>(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
InstanceCreationExpression
|
||||
@@ -1012,24 +994,15 @@ class A<T> {
|
||||
}
|
||||
''');
|
||||
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
f() {
|
||||
prefix.A.new<int>(0);
|
||||
// ^^^^^
|
||||
// [diag.wrongNumberOfTypeArgumentsConstructor] The constructor 'prefix.A.new' doesn't have type parameters.
|
||||
}
|
||||
''',
|
||||
[
|
||||
error(
|
||||
diag.wrongNumberOfTypeArgumentsConstructor,
|
||||
48,
|
||||
5,
|
||||
messageContains: ["The constructor 'prefix.A.new'"],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
''');
|
||||
var node = findNode.instanceCreation('new<int>(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
InstanceCreationExpression
|
||||
@@ -1083,14 +1056,13 @@ class A {
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
f() {
|
||||
prefix.foo.bar(0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('bar(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1133,14 +1105,13 @@ class A<T> {
|
||||
typedef X<T> = A<T>;
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
void f() {
|
||||
prefix.X.named(0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.instanceCreation('X.named(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
InstanceCreationExpression
|
||||
@@ -1178,7 +1149,7 @@ InstanceCreationExpression
|
||||
}
|
||||
|
||||
test_targetSimpleIdentifier_class_constructor() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A<T> {
|
||||
A.named(T a);
|
||||
}
|
||||
@@ -1221,25 +1192,17 @@ InstanceCreationExpression
|
||||
}
|
||||
|
||||
test_targetSimpleIdentifier_class_constructor_typeArguments() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A<T, U> {
|
||||
A.named(int a);
|
||||
}
|
||||
|
||||
f() {
|
||||
A.named<int, String>(0);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [diag.wrongNumberOfTypeArgumentsConstructor] The constructor 'A.named' doesn't have type parameters.
|
||||
}
|
||||
''',
|
||||
[
|
||||
error(
|
||||
diag.wrongNumberOfTypeArgumentsConstructor,
|
||||
52,
|
||||
13,
|
||||
messageContains: ["The constructor 'A.named'"],
|
||||
),
|
||||
],
|
||||
);
|
||||
''');
|
||||
|
||||
// TODO(scheglov): Move type arguments
|
||||
var node = findNode.instanceCreation('named<int, String>(0);');
|
||||
@@ -1287,25 +1250,17 @@ InstanceCreationExpression
|
||||
}
|
||||
|
||||
test_targetSimpleIdentifier_class_constructor_typeArguments_new() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A<T, U> {
|
||||
A.new(int a);
|
||||
}
|
||||
|
||||
f() {
|
||||
A.new<int, String>(0);
|
||||
// ^^^^^^^^^^^^^
|
||||
// [diag.wrongNumberOfTypeArgumentsConstructor] The constructor 'A.new' doesn't have type parameters.
|
||||
}
|
||||
''',
|
||||
[
|
||||
error(
|
||||
diag.wrongNumberOfTypeArgumentsConstructor,
|
||||
48,
|
||||
13,
|
||||
messageContains: ["The constructor 'A.new'"],
|
||||
),
|
||||
],
|
||||
);
|
||||
''');
|
||||
|
||||
// TODO(scheglov): Move type arguments
|
||||
var node = findNode.instanceCreation('new<int, String>(0);');
|
||||
@@ -1353,7 +1308,7 @@ InstanceCreationExpression
|
||||
}
|
||||
|
||||
test_targetSimpleIdentifier_class_staticMethod() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {
|
||||
static void foo(int a) {}
|
||||
}
|
||||
@@ -1362,7 +1317,6 @@ f() {
|
||||
A.foo(0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('foo(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1395,14 +1349,13 @@ class A<T, U> {
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
f() {
|
||||
prefix.A<int, String>(0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.instanceCreation('A<int, String>(0);');
|
||||
assertResolvedNodeText(node, r'''
|
||||
InstanceCreationExpression
|
||||
@@ -1453,14 +1406,13 @@ extension E<T> on A {
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
f(prefix.A a) {
|
||||
prefix.E<int>(a).foo();
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.extensionOverride('E<int>(a)');
|
||||
assertResolvedNodeText(node, r'''
|
||||
ExtensionOverride
|
||||
@@ -1499,7 +1451,7 @@ ExtensionOverride
|
||||
void A<T, U>(int a) {}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'a.dart' as prefix;
|
||||
|
||||
f() {
|
||||
@@ -1550,7 +1502,7 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_targetSimpleIdentifier_typeAlias_interfaceType_constructor() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A<T> {
|
||||
A.named(T a);
|
||||
}
|
||||
@@ -1598,16 +1550,15 @@ InstanceCreationExpression
|
||||
@reflectiveTest
|
||||
class AstRewritePrefixedIdentifierTest extends PubPackageResolutionTest {
|
||||
test_constructorReference_inAssignment_onLeftSide() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class C {}
|
||||
|
||||
void f() {
|
||||
C.new = 1;
|
||||
// ^^^
|
||||
// [diag.undefinedSetter] The setter 'new' isn't defined for the type 'C'.
|
||||
}
|
||||
''',
|
||||
[error(diag.undefinedSetter, 27, 3)],
|
||||
);
|
||||
''');
|
||||
|
||||
var identifier = findNode.prefixed('C.new');
|
||||
// The left side of the assignment is resolved by
|
||||
@@ -1619,7 +1570,7 @@ void f() {
|
||||
}
|
||||
|
||||
test_constructorReference_inAssignment_onRightSide() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class C {}
|
||||
|
||||
Function? f;
|
||||
|
||||
@@ -1,321 +0,0 @@
|
||||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_collection_resolution.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
// TODO(scheglov): implement augmentation
|
||||
// defineReflectiveTests(AugmentedExpressionResolutionTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class AugmentedExpressionResolutionTest extends PubPackageResolutionTest {
|
||||
test_class_field() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
class A {
|
||||
num foo = 0;
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
part of 'a.dart';
|
||||
|
||||
augment class A {
|
||||
augment num foo = augmented;
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.singleVariableDeclaration.initializer!;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: package:test/a.dart::<fragment>::@class::A::@field::foo
|
||||
fragment: package:test/a.dart::<fragment>::@class::A::@field::foo
|
||||
staticType: int
|
||||
''');
|
||||
}
|
||||
|
||||
test_class_getter() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
class A {
|
||||
int get foo => 0;
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
part of 'a.dart';
|
||||
|
||||
augment class A {
|
||||
augment int get foo {
|
||||
return augmented;
|
||||
}
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.singleReturnStatement;
|
||||
assertResolvedNodeText(node, r'''
|
||||
ReturnStatement
|
||||
returnKeyword: return
|
||||
expression: AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: package:test/a.dart::<fragment>::@class::A::@getter::foo
|
||||
fragment: package:test/a.dart::<fragment>::@class::A::@getter::foo
|
||||
staticType: int
|
||||
semicolon: ;
|
||||
''');
|
||||
}
|
||||
|
||||
test_class_setter() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
class A {
|
||||
set foo(int _) {}
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
part of 'a.dart';
|
||||
|
||||
augment class A {
|
||||
augment set foo(int _) {
|
||||
augmented = 0;
|
||||
}
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.singleBlock;
|
||||
// TODO(scheglov): implement augmentation
|
||||
assertResolvedNodeText(node, r'''
|
||||
Block
|
||||
leftBracket: {
|
||||
statements
|
||||
ExpressionStatement
|
||||
expression: AssignmentExpression
|
||||
leftHandSide: AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: package:test/a.dart::<fragment>::@class::A::@setter::foo
|
||||
fragment: package:test/a.dart::<fragment>::@class::A::@setter::foo
|
||||
staticType: null
|
||||
operator: =
|
||||
rightHandSide: IntegerLiteral
|
||||
literal: 0
|
||||
parameter: package:test/a.dart::<fragment>::@class::A::@setter::foo::@parameter::_
|
||||
staticType: int
|
||||
readElement: <null>
|
||||
readElement2: <null>
|
||||
readType: null
|
||||
writeElement: package:test/a.dart::@fragment::package:test/test.dart::@classAugmentation::A::@setterAugmentation::foo
|
||||
writeElement2: package:test/a.dart::<fragment>::@class::A::@setter::foo#element
|
||||
writeType: int
|
||||
staticElement: <null>
|
||||
element: <null>
|
||||
staticType: int
|
||||
semicolon: ;
|
||||
rightBracket: }
|
||||
''');
|
||||
}
|
||||
|
||||
test_class_setter_inGetter() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
class A {
|
||||
int foo = 0;
|
||||
}
|
||||
''');
|
||||
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
part of 'a.dart';
|
||||
|
||||
augment class A {
|
||||
augment int get foo {
|
||||
augmented = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
''',
|
||||
[error(diag.augmentedExpressionIsNotSetter, 65, 9)],
|
||||
);
|
||||
|
||||
var node = findNode.singleAssignmentExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AssignmentExpression
|
||||
leftHandSide: AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: <null>
|
||||
fragment: <null>
|
||||
staticType: null
|
||||
operator: =
|
||||
rightHandSide: IntegerLiteral
|
||||
literal: 0
|
||||
parameter: <null>
|
||||
staticType: int
|
||||
readElement: <null>
|
||||
readElement2: <null>
|
||||
readType: null
|
||||
writeElement: <null>
|
||||
writeElement2: <null>
|
||||
writeType: InvalidType
|
||||
staticElement: <null>
|
||||
element: <null>
|
||||
staticType: int
|
||||
''');
|
||||
}
|
||||
|
||||
test_class_setter_inMethod() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
class A {
|
||||
void foo() {}
|
||||
}
|
||||
''');
|
||||
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
part of 'a.dart';
|
||||
|
||||
augment class A {
|
||||
augment void foo() {
|
||||
augmented = 0;
|
||||
}
|
||||
}
|
||||
''',
|
||||
[error(diag.augmentedExpressionIsNotSetter, 64, 9)],
|
||||
);
|
||||
|
||||
var node = findNode.singleAssignmentExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AssignmentExpression
|
||||
leftHandSide: AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: <null>
|
||||
fragment: <null>
|
||||
staticType: null
|
||||
operator: =
|
||||
rightHandSide: IntegerLiteral
|
||||
literal: 0
|
||||
parameter: <null>
|
||||
staticType: int
|
||||
readElement: <null>
|
||||
readElement2: <null>
|
||||
readType: null
|
||||
writeElement: <null>
|
||||
writeElement2: <null>
|
||||
writeType: InvalidType
|
||||
staticElement: <null>
|
||||
element: <null>
|
||||
staticType: int
|
||||
''');
|
||||
}
|
||||
|
||||
test_topLevel_getter() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
int get foo => 0;
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
part of 'a.dart';
|
||||
|
||||
augment int get foo {
|
||||
return augmented;
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.singleReturnStatement;
|
||||
assertResolvedNodeText(node, r'''
|
||||
ReturnStatement
|
||||
returnKeyword: return
|
||||
expression: AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: package:test/a.dart::<fragment>::@getter::foo
|
||||
fragment: package:test/a.dart::<fragment>::@getter::foo
|
||||
staticType: int
|
||||
semicolon: ;
|
||||
''');
|
||||
}
|
||||
|
||||
test_topLevel_setter() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
set foo(int _) {}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
part of 'a.dart';
|
||||
|
||||
augment set foo(int _) {
|
||||
augmented = 0;
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.singleBlock;
|
||||
// TODO(scheglov): implement augmentation
|
||||
assertResolvedNodeText(node, r'''
|
||||
Block
|
||||
leftBracket: {
|
||||
statements
|
||||
ExpressionStatement
|
||||
expression: AssignmentExpression
|
||||
leftHandSide: AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: package:test/a.dart::<fragment>::@setter::foo
|
||||
fragment: package:test/a.dart::<fragment>::@setter::foo
|
||||
staticType: null
|
||||
operator: =
|
||||
rightHandSide: IntegerLiteral
|
||||
literal: 0
|
||||
parameter: package:test/a.dart::<fragment>::@setter::foo::@parameter::_
|
||||
staticType: int
|
||||
readElement: <null>
|
||||
readElement2: <null>
|
||||
readType: null
|
||||
writeElement: package:test/a.dart::@fragment::package:test/test.dart::@setterAugmentation::foo
|
||||
writeElement2: package:test/a.dart::<fragment>::@setter::foo#element
|
||||
writeType: int
|
||||
staticElement: <null>
|
||||
element: <null>
|
||||
staticType: int
|
||||
semicolon: ;
|
||||
rightBracket: }
|
||||
''');
|
||||
}
|
||||
|
||||
test_topLevel_variable() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
|
||||
num foo = 0;
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
part of 'a.dart';
|
||||
|
||||
augment num foo = augmented;
|
||||
''');
|
||||
|
||||
var node = findNode.singleVariableDeclaration.initializer!;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AugmentedExpression
|
||||
augmentedKeyword: augmented
|
||||
element: package:test/a.dart::<fragment>::@topLevelVariable::foo
|
||||
fragment: package:test/a.dart::<fragment>::@topLevelVariable::foo
|
||||
staticType: int
|
||||
''');
|
||||
}
|
||||
}
|
||||
@@ -2,75 +2,70 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_collection_resolution.dart';
|
||||
import 'node_text_expectations.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(AwaitExpressionResolutionTest);
|
||||
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class AwaitExpressionResolutionTest extends PubPackageResolutionTest {
|
||||
test_future() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(Future<int> a) async {
|
||||
await a;
|
||||
}
|
||||
''');
|
||||
|
||||
assertType(findNode.awaitExpression('await a'), 'int');
|
||||
}
|
||||
|
||||
test_futureOr() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'dart:async';
|
||||
|
||||
f(FutureOr<int> a) async {
|
||||
await a;
|
||||
}
|
||||
''');
|
||||
|
||||
assertType(findNode.awaitExpression('await a'), 'int');
|
||||
}
|
||||
|
||||
test_futureOrQ() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'dart:async';
|
||||
|
||||
f(FutureOr<int>? a) async {
|
||||
await a;
|
||||
}
|
||||
''');
|
||||
|
||||
assertType(findNode.awaitExpression('await a'), 'int?');
|
||||
}
|
||||
|
||||
test_futureQ() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(Future<int>? a) async {
|
||||
await a;
|
||||
}
|
||||
''');
|
||||
|
||||
assertType(findNode.awaitExpression('await a'), 'int?');
|
||||
}
|
||||
|
||||
test_super() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {
|
||||
void f() async {
|
||||
await super;
|
||||
// ^^^^^
|
||||
// [diag.missingAssignableSelector] Missing selector such as '.identifier' or '[0]'.
|
||||
}
|
||||
}
|
||||
''',
|
||||
[error(diag.missingAssignableSelector, 39, 5)],
|
||||
);
|
||||
|
||||
''');
|
||||
var node = findNode.singleAwaitExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AwaitExpression
|
||||
@@ -83,7 +78,7 @@ AwaitExpression
|
||||
}
|
||||
|
||||
test_super_property() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {
|
||||
void f() async {
|
||||
await super.hashCode;
|
||||
@@ -110,14 +105,13 @@ AwaitExpression
|
||||
}
|
||||
|
||||
test_unresolved_identifier() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f() async {
|
||||
await unresolved;
|
||||
// ^^^^^^^^^^
|
||||
// [diag.undefinedIdentifier] Undefined name 'unresolved'.
|
||||
}
|
||||
''',
|
||||
[error(diag.undefinedIdentifier, 25, 10)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.singleAwaitExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -132,16 +126,15 @@ AwaitExpression
|
||||
}
|
||||
|
||||
test_unresolved_prefixedIdentifier() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
import 'dart:math' as prefix;
|
||||
|
||||
void f() async {
|
||||
await prefix.unresolved;
|
||||
// ^^^^^^^^^^
|
||||
// [diag.undefinedPrefixedName] The name 'unresolved' is being referenced through the prefix 'prefix', but it isn't defined in any of the libraries imported using that prefix.
|
||||
}
|
||||
''',
|
||||
[error(diag.undefinedPrefixedName, 63, 10)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.singleAwaitExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -164,14 +157,13 @@ AwaitExpression
|
||||
}
|
||||
|
||||
test_unresolved_propertyAccess() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f() async {
|
||||
await 0.isEven.unresolved;
|
||||
// ^^^^^^^^^^
|
||||
// [diag.undefinedGetter] The getter 'unresolved' isn't defined for the type 'bool'.
|
||||
}
|
||||
''',
|
||||
[error(diag.undefinedGetter, 34, 10)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.singleAwaitExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
|
||||
@@ -20,7 +20,7 @@ main() {
|
||||
class BinaryExpressionResolutionTest extends PubPackageResolutionTest
|
||||
with BinaryExpressionResolutionTestCases {
|
||||
test_eqEq_alwaysBool() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
extension type MyBool(bool it) implements bool {}
|
||||
|
||||
class A {
|
||||
@@ -31,7 +31,6 @@ void f(A a) {
|
||||
a == 0;
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.binary('a == 0');
|
||||
assertResolvedNodeText(node, r'''
|
||||
BinaryExpression
|
||||
@@ -51,14 +50,13 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_eqEq_switchExpression_left() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f(Object? x) {
|
||||
(switch (x) {
|
||||
_ => 1,
|
||||
} == 0);
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.binary('== 0');
|
||||
assertResolvedNodeText(node, r'''
|
||||
BinaryExpression
|
||||
@@ -95,14 +93,13 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_eqEq_switchExpression_right() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f(Object? x) {
|
||||
0 == switch (x) {
|
||||
_ => 1,
|
||||
};
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.binary('0 ==');
|
||||
assertResolvedNodeText(node, r'''
|
||||
BinaryExpression
|
||||
@@ -139,7 +136,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_expression_recordType_hasOperator() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f((String,) a) {
|
||||
a + 0;
|
||||
}
|
||||
@@ -148,7 +145,6 @@ extension on (String,) {
|
||||
int operator +(int other) => 0;
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.binary('+ 0');
|
||||
assertResolvedNodeText(node, r'''
|
||||
BinaryExpression
|
||||
@@ -168,15 +164,13 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_expression_recordType_noOperator() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f((String,) a) {
|
||||
a + 0;
|
||||
// ^
|
||||
// [diag.undefinedOperator] The operator '+' isn't defined for the type '(String,)'.
|
||||
}
|
||||
''',
|
||||
[error(diag.undefinedOperator, 26, 1)],
|
||||
);
|
||||
|
||||
''');
|
||||
var node = findNode.binary('+ 0');
|
||||
assertResolvedNodeText(node, r'''
|
||||
BinaryExpression
|
||||
@@ -196,7 +190,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_gtGtGt() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {
|
||||
A operator >>>(int amount) => this;
|
||||
}
|
||||
@@ -205,7 +199,6 @@ void f(A a) {
|
||||
a >>> 3;
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.singleBinaryExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
BinaryExpression
|
||||
@@ -225,7 +218,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_ifNull_left_nullableContext() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
T f<T>(T t) => t;
|
||||
|
||||
int g() => f(null) ?? 0;
|
||||
@@ -264,7 +257,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_ifNull_lubUsedEvenIfItDoesNotSatisfyContext() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
// @dart=3.3
|
||||
class A {}
|
||||
class B1 extends A {}
|
||||
@@ -298,7 +291,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_ifNull_nullableInt_int() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f(int? x, int y) {
|
||||
x ?? y;
|
||||
}
|
||||
@@ -323,7 +316,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_ifNull_nullableInt_nullableDouble() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f(int? x, double? y) {
|
||||
x ?? y;
|
||||
}
|
||||
@@ -348,7 +341,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_ifNull_nullableInt_nullableInt() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f(int? x) {
|
||||
x ?? x;
|
||||
}
|
||||
@@ -373,7 +366,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_extensionType_int() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
extension type Int(int i) implements int {
|
||||
Int operator +(int other) {
|
||||
return Int(i + other);
|
||||
@@ -405,7 +398,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_never() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
f(int a, Never b) {
|
||||
a + b;
|
||||
}
|
||||
@@ -430,14 +423,15 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_never_int() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(Never a, int b) {
|
||||
a + b;
|
||||
//^
|
||||
// [diag.receiverOfTypeNever] The receiver is of type 'Never', and will never complete with a value.
|
||||
// ^^^
|
||||
// [diag.deadCode] Dead code.
|
||||
}
|
||||
''',
|
||||
[error(diag.receiverOfTypeNever, 22, 1), error(diag.deadCode, 24, 3)],
|
||||
);
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('a + b'), r'''
|
||||
BinaryExpression
|
||||
@@ -458,7 +452,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_switchExpression_left() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f(Object? x) {
|
||||
(switch (x) {
|
||||
_ => 1,
|
||||
@@ -502,7 +496,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_switchExpression_right() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f(Object? x) {
|
||||
0 + switch (x) {
|
||||
_ => 1,
|
||||
@@ -546,18 +540,17 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_star_syntheticOperand_both() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f() {
|
||||
final v = * ;
|
||||
// ^
|
||||
// [diag.unusedLocalVariable] The value of the local variable 'v' isn't used.
|
||||
// ^
|
||||
// [diag.missingIdentifier] Expected an identifier.
|
||||
// ^
|
||||
// [diag.missingIdentifier] Expected an identifier.
|
||||
}
|
||||
''',
|
||||
[
|
||||
error(diag.unusedLocalVariable, 19, 1),
|
||||
error(diag.missingIdentifier, 23, 1),
|
||||
error(diag.missingIdentifier, 25, 1),
|
||||
],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.singleBinaryExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -579,17 +572,15 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_star_syntheticOperand_left() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f() {
|
||||
final v = * 2;
|
||||
// ^
|
||||
// [diag.unusedLocalVariable] The value of the local variable 'v' isn't used.
|
||||
// ^
|
||||
// [diag.missingIdentifier] Expected an identifier.
|
||||
}
|
||||
''',
|
||||
[
|
||||
error(diag.unusedLocalVariable, 19, 1),
|
||||
error(diag.missingIdentifier, 23, 1),
|
||||
],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.singleBinaryExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -610,17 +601,15 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_star_syntheticOperand_right() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f() {
|
||||
final v = 2 * ;
|
||||
// ^
|
||||
// [diag.unusedLocalVariable] The value of the local variable 'v' isn't used.
|
||||
// ^
|
||||
// [diag.missingIdentifier] Expected an identifier.
|
||||
}
|
||||
''',
|
||||
[
|
||||
error(diag.unusedLocalVariable, 19, 1),
|
||||
error(diag.missingIdentifier, 27, 1),
|
||||
],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.singleBinaryExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -641,7 +630,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_superQualifier_plus() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {
|
||||
int operator +(int other) => 0;
|
||||
}
|
||||
@@ -673,7 +662,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_thisExpression_plus() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
class A {
|
||||
int operator +(int other) => 0;
|
||||
|
||||
@@ -1197,17 +1186,15 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_double_context_int() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(double a) {
|
||||
h(a + f());
|
||||
// ^^^^^^^
|
||||
// [diag.argumentTypeNotAssignable] The argument type 'double' can't be assigned to the parameter type 'int'.
|
||||
}
|
||||
h(int x) {}
|
||||
''',
|
||||
[error(diag.argumentTypeNotAssignable, 45, 7)],
|
||||
);
|
||||
|
||||
''');
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1227,13 +1214,12 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_double_context_none() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(double a) {
|
||||
a + f();
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1253,12 +1239,11 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_double_dynamic() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(double a, dynamic b) {
|
||||
a + b;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('a + b'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: SimpleIdentifier
|
||||
@@ -1278,14 +1263,13 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_context_double() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(int a) {
|
||||
h(a + f());
|
||||
}
|
||||
h(double x) {}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1305,14 +1289,13 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_int_context_int() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(int a) {
|
||||
h(a + f());
|
||||
}
|
||||
h(int x) {}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1332,14 +1315,13 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_int_context_int_target_rewritten() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(int Function() a) {
|
||||
h(a() + f());
|
||||
}
|
||||
h(int x) {}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1359,20 +1341,18 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_int_context_int_via_extension_explicit() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
extension E on int {
|
||||
String operator+(num x) => '';
|
||||
}
|
||||
T f<T>() => throw Error();
|
||||
g(int a) {
|
||||
h(E(a) + f());
|
||||
// ^^^^^^^^^^
|
||||
// [diag.argumentTypeNotAssignable] The argument type 'String' can't be assigned to the parameter type 'int'.
|
||||
}
|
||||
h(int x) {}
|
||||
''',
|
||||
[error(diag.argumentTypeNotAssignable, 98, 10)],
|
||||
);
|
||||
|
||||
''');
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1392,13 +1372,12 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_int_context_none() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(int a) {
|
||||
a + f();
|
||||
}
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
MethodInvocation
|
||||
@@ -1418,12 +1397,11 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_int_double() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(int a, double b) {
|
||||
a + b;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('a + b'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: SimpleIdentifier
|
||||
@@ -1443,12 +1421,11 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_dynamic() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(int a, dynamic b) {
|
||||
a + b;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('a + b'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: SimpleIdentifier
|
||||
@@ -1468,12 +1445,11 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_int() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(int a, int b) {
|
||||
a + b;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('a + b'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: SimpleIdentifier
|
||||
@@ -1493,12 +1469,11 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_int_target_rewritten() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
f(int Function() a, int b) {
|
||||
a() + b;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('a() + b'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: FunctionExpressionInvocation
|
||||
@@ -1525,7 +1500,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_int_via_extension_explicit() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
extension E on int {
|
||||
String operator+(int other) => '';
|
||||
}
|
||||
@@ -1533,7 +1508,6 @@ f(int a, int b) {
|
||||
E(a) + b;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('E(a) + b'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: ExtensionOverride
|
||||
@@ -1563,12 +1537,11 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_num() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(int a, num b) {
|
||||
a + b;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('a + b'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: SimpleIdentifier
|
||||
@@ -1588,7 +1561,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_int_typeVariable_via_extension() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class Foo {}
|
||||
|
||||
extension FooExtension<F extends Foo> on F {
|
||||
@@ -1597,7 +1570,6 @@ extension FooExtension<F extends Foo> on F {
|
||||
F get gg => this + 1;
|
||||
}
|
||||
''');
|
||||
|
||||
assertResolvedNodeText(findNode.binary('this + 1'), r'''
|
||||
BinaryExpression
|
||||
leftOperand: ThisExpression
|
||||
@@ -1617,15 +1589,13 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_invalidType_int() async {
|
||||
await assertErrorsInCode(
|
||||
r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
void f() {
|
||||
x + 0;
|
||||
//^
|
||||
// [diag.undefinedIdentifier] Undefined name 'x'.
|
||||
}
|
||||
''',
|
||||
[error(diag.undefinedIdentifier, 13, 1)],
|
||||
);
|
||||
|
||||
''');
|
||||
var node = findNode.binary('x + 0');
|
||||
assertResolvedNodeText(node, r'''
|
||||
BinaryExpression
|
||||
@@ -1645,16 +1615,15 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_num_context_int() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(num a) {
|
||||
h(a + f());
|
||||
// ^^^^^^^
|
||||
// [diag.argumentTypeNotAssignable] The argument type 'num' can't be assigned to the parameter type 'int'.
|
||||
}
|
||||
h(int x) {}
|
||||
''',
|
||||
[error(diag.argumentTypeNotAssignable, 42, 7)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -1675,19 +1644,18 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_other_context_int() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class A {
|
||||
num operator+(String x);
|
||||
}
|
||||
T f<T>() => throw Error();
|
||||
g(A a) {
|
||||
h(a + f());
|
||||
// ^^^^^^^
|
||||
// [diag.argumentTypeNotAssignable] The argument type 'num' can't be assigned to the parameter type 'int'.
|
||||
}
|
||||
h(int x) {}
|
||||
''',
|
||||
[error(diag.argumentTypeNotAssignable, 88, 7)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -1708,8 +1676,7 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_other_context_int_via_extension_explicit() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
extension E on A {
|
||||
String operator+(num x) => '';
|
||||
@@ -1717,11 +1684,11 @@ extension E on A {
|
||||
T f<T>() => throw Error();
|
||||
g(A a) {
|
||||
h(E(a) + f());
|
||||
// ^^^^^^^^^^
|
||||
// [diag.argumentTypeNotAssignable] The argument type 'String' can't be assigned to the parameter type 'int'.
|
||||
}
|
||||
h(int x) {}
|
||||
''',
|
||||
[error(diag.argumentTypeNotAssignable, 105, 10)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -1742,8 +1709,7 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_other_context_int_via_extension_implicit() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
extension E on A {
|
||||
String operator+(num x) => '';
|
||||
@@ -1751,11 +1717,11 @@ extension E on A {
|
||||
T f<T>() => throw Error();
|
||||
g(A a) {
|
||||
h(a + f());
|
||||
// ^^^^^^^
|
||||
// [diag.argumentTypeNotAssignable] The argument type 'String' can't be assigned to the parameter type 'int'.
|
||||
}
|
||||
h(int x) {}
|
||||
''',
|
||||
[error(diag.argumentTypeNotAssignable, 105, 7)],
|
||||
);
|
||||
''');
|
||||
|
||||
var node = findNode.methodInvocation('f()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
@@ -1776,7 +1742,7 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_plus_other_double() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
abstract class A {
|
||||
String operator+(double other);
|
||||
}
|
||||
@@ -1804,7 +1770,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_other_int_via_extension_explicit() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
extension E on A {
|
||||
String operator+(int other) => '';
|
||||
@@ -1843,7 +1809,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_plus_other_int_via_extension_implicit() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
extension E on A {
|
||||
String operator+(int other) => '';
|
||||
@@ -1872,7 +1838,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_receiverTypeParameter_bound_dynamic() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f<T extends dynamic>(T a) {
|
||||
a + 0;
|
||||
}
|
||||
@@ -1896,7 +1862,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_receiverTypeParameter_bound_num() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f<T extends num>(T a) {
|
||||
a + 0;
|
||||
}
|
||||
@@ -1920,7 +1886,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_slash() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(int a, int b) {
|
||||
a / b;
|
||||
}
|
||||
@@ -1945,7 +1911,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_star_int_context_int() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
T f<T>() => throw Error();
|
||||
g(int a) {
|
||||
h(a * f());
|
||||
@@ -1972,7 +1938,7 @@ MethodInvocation
|
||||
}
|
||||
|
||||
test_star_int_double() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(int a, double b) {
|
||||
a * b;
|
||||
}
|
||||
@@ -1997,7 +1963,7 @@ BinaryExpression
|
||||
}
|
||||
|
||||
test_star_int_int() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
await resolveTestCodeWithDiagnostics(r'''
|
||||
f(int a, int b) {
|
||||
a * b;
|
||||
}
|
||||
@@ -2025,7 +1991,7 @@ BinaryExpression
|
||||
@reflectiveTest
|
||||
class InferenceUpdate3Test extends PubPackageResolutionTest {
|
||||
test_ifNull_contextIsConvertedToATypeUsingGreatestClosure() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
class B1<T> extends A {}
|
||||
class B2<T> extends A {}
|
||||
@@ -2058,7 +2024,7 @@ f(C1<int>? c1, C2<double> c2) {
|
||||
}
|
||||
|
||||
test_ifNull_contextNotUsedIfLhsDoesNotSatisfyContext() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
class B1 extends A {}
|
||||
class B2 extends A {}
|
||||
@@ -2090,7 +2056,7 @@ f(B2? b2, C1 c1, Object? o) {
|
||||
}
|
||||
|
||||
test_ifNull_contextNotUsedIfRhsDoesNotSatisfyContext() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
class B1 extends A {}
|
||||
class B2 extends A {}
|
||||
@@ -2122,7 +2088,7 @@ f(C1? c1, B2 b2, Object? o) {
|
||||
}
|
||||
|
||||
test_ifNull_contextUsedInsteadOfLubIfLubDoesNotSatisfyContext() async {
|
||||
await assertNoErrorsInCode('''
|
||||
await resolveTestCodeWithDiagnostics('''
|
||||
class A {}
|
||||
class B1 extends A {}
|
||||
class B2 extends A {}
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'adjacent_strings_test.dart' as adjacent_strings;
|
||||
import 'as_expression_test.dart' as as_expression;
|
||||
import 'assignment_test.dart' as assignment;
|
||||
import 'ast_rewrite_test.dart' as ast_rewrite;
|
||||
import 'augmented_expression_test.dart' as augmented_expression;
|
||||
import 'await_expression_test.dart' as await_expression;
|
||||
import 'binary_expression_test.dart' as binary_expression;
|
||||
import 'cascade_expression_resolution_test.dart'
|
||||
@@ -129,7 +128,6 @@ main() {
|
||||
as_expression.main();
|
||||
assignment.main();
|
||||
ast_rewrite.main();
|
||||
augmented_expression.main();
|
||||
await_expression.main();
|
||||
binary_expression.main();
|
||||
cascade_expression_resolution_test.main();
|
||||
|
||||
Reference in New Issue
Block a user