Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Unified Diff: pkg/analyzer/test/generated/static_type_warning_code_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/generated/static_type_warning_code_test.dart
diff --git a/pkg/analyzer/test/generated/static_type_warning_code_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
index cab96a4a2c4a699d33b25de50fc4254a271a912e..86811cbcc8af35858bebd3faf04f2cfdb9f34269 100644
--- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
@@ -26,8 +26,7 @@ class StaticTypeWarningCodeTest extends ResolverTestCase {
fail_method_lookup_mixin_of_extends() async {
// See dartbug.com/25605
resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
- await assertErrorsInUnverifiedCode(
- '''
+ await assertErrorsInUnverifiedCode('''
class A { a() => null; }
class B {}
abstract class M extends A {}
@@ -35,19 +34,17 @@ class T = B with M; // Warning: B does not extend A
main() {
new T().a(); // Warning: The method 'a' is not defined for the class 'T'
}
-''',
- [
- // TODO(paulberry): when dartbug.com/25614 is fixed, add static warning
- // code for "B does not extend A".
- StaticTypeWarningCode.UNDEFINED_METHOD
- ]);
+''', [
+ // TODO(paulberry): when dartbug.com/25614 is fixed, add static warning
+ // code for "B does not extend A".
+ StaticTypeWarningCode.UNDEFINED_METHOD
+ ]);
}
fail_method_lookup_mixin_of_implements() async {
// See dartbug.com/25605
resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
- await assertErrorsInUnverifiedCode(
- '''
+ await assertErrorsInUnverifiedCode('''
class A { a() => null; }
class B {}
abstract class M implements A {}
@@ -55,18 +52,16 @@ class T = B with M; // Warning: Missing concrete implementation of 'A.a'
main() {
new T().a(); // Warning: The method 'a' is not defined for the class 'T'
}
-''',
- [
- StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
- StaticTypeWarningCode.UNDEFINED_METHOD
- ]);
+''', [
+ StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
+ StaticTypeWarningCode.UNDEFINED_METHOD
+ ]);
}
fail_method_lookup_mixin_of_mixin() async {
// See dartbug.com/25605
resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
- await assertErrorsInUnverifiedCode(
- '''
+ await assertErrorsInUnverifiedCode('''
class A {}
class B { b() => null; }
class C {}
@@ -75,15 +70,13 @@ class T = C with M;
main() {
new T().b();
}
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
fail_method_lookup_mixin_of_mixin_application() async {
// See dartbug.com/25605
resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true);
- await assertErrorsInUnverifiedCode(
- '''
+ await assertErrorsInUnverifiedCode('''
class A { a() => null; }
class B {}
class C {}
@@ -92,30 +85,25 @@ class T = C with M;
main() {
new T().a();
}
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
fail_typeArgumentNotMatchingBounds_ofFunctionTypeAlias() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
typedef F<T extends A>();
F<B> fff;
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
fail_undefinedEnumConstant() async {
// We need a way to set the parseEnum flag in the parser to true.
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
enum E { ONE }
E e() {
return E.TWO;
-}''',
- [StaticTypeWarningCode.UNDEFINED_ENUM_CONSTANT]);
+}''', [StaticTypeWarningCode.UNDEFINED_ENUM_CONSTANT]);
}
test_ambiguousImport_function() async {
@@ -123,14 +111,10 @@ E e() {
import 'lib1.dart';
import 'lib2.dart';
g() { return f(); }''');
- addNamedSource(
- "/lib1.dart",
- r'''
+ addNamedSource("/lib1.dart", r'''
library lib1;
f() {}''');
- addNamedSource(
- "/lib2.dart",
- r'''
+ addNamedSource("/lib2.dart", r'''
library lib2;
f() {}''');
await computeAnalysisResult(source);
@@ -143,8 +127,7 @@ f() {}''');
// assignment occurred outside an assert statement. (Note that it is a
// dubious practice for the computation of an assert message to have side
// effects, since it is only evaluated if the assert fails).
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class C {
void foo() {}
}
@@ -155,33 +138,28 @@ f(Object x) {
assert(true, () { x = new C(); return 'msg'; }());
}
}
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
// Do not verify since `x.foo()` fails to resolve.
}
test_await_flattened() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
Future<Future<int>> ffi() => null;
f() async {
Future<int> b = await ffi(); // Warning: int not assignable to Future<int>
}
-''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_await_simple() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
Future<int> fi() => null;
f() async {
String a = await fi(); // Warning: int not assignable to String
}
-''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_awaitForIn_declaredVariableRightType() async {
@@ -195,15 +173,13 @@ f() async {
}
test_awaitForIn_declaredVariableWrongType() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
f() async {
Stream<String> stream;
await for (int i in stream) {}
}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
test_awaitForIn_downcast() async {
@@ -247,26 +223,22 @@ f() async {
}
test_awaitForIn_existingVariableWrongType() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
f() async {
Stream<String> stream;
int i;
await for (i in stream) {}
}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
test_awaitForIn_notStream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f() async {
await for (var i in true) {}
}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
}
test_awaitForIn_streamOfDynamic() async {
@@ -290,8 +262,7 @@ f() async {
}
test_bug21912() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class A {}
class B extends A {}
@@ -310,38 +281,31 @@ void main() {
left = t2;
}
}
-''',
- [
- StaticTypeWarningCode.INVALID_ASSIGNMENT,
- StaticTypeWarningCode.INVALID_ASSIGNMENT
- ]);
+''', [
+ StaticTypeWarningCode.INVALID_ASSIGNMENT,
+ StaticTypeWarningCode.INVALID_ASSIGNMENT
+ ]);
}
test_expectedOneListTypeArgument() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
main() {
<int, int> [];
-}''',
- [StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS]);
+}''', [StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS]);
}
test_expectedTwoMapTypeArguments_one() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
main() {
<int> {};
-}''',
- [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
+}''', [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
}
test_expectedTwoMapTypeArguments_three() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
main() {
<int, int, int> {};
-}''',
- [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
+}''', [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
}
test_forIn_declaredVariableRightType() async {
@@ -353,13 +317,11 @@ f() {
}
test_forIn_declaredVariableWrongType() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f() {
for (int i in <String>[]) {}
}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
test_forIn_downcast() async {
@@ -406,14 +368,12 @@ f() {
}
test_forIn_existingVariableWrongType() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f() {
int i;
for (i in <String>[]) {}
}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
test_forIn_iterableOfDynamic() async {
@@ -425,13 +385,11 @@ f() {
}
test_forIn_notIterable() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f() {
for (var i in true) {}
}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
}
test_forIn_object() async {
@@ -444,15 +402,13 @@ f() {
}
test_forIn_typeBoundBad() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class Foo<T extends Iterable<int>> {
void method(T iterable) {
for (String i in iterable) {}
}
}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+''', [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
}
test_forIn_typeBoundGood() async {
@@ -474,88 +430,73 @@ f() {
}
test_illegalAsyncGeneratorReturnType_function_nonStream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
int f() async* {}
-''',
- [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
test_illegalAsyncGeneratorReturnType_function_subtypeOfStream() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
abstract class SubStream<T> implements Stream<T> {}
SubStream<int> f() async* {}
-''',
- [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
test_illegalAsyncGeneratorReturnType_method_nonStream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class C {
int f() async* {}
}
-''',
- [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
test_illegalAsyncGeneratorReturnType_method_subtypeOfStream() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
abstract class SubStream<T> implements Stream<T> {}
class C {
SubStream<int> f() async* {}
}
-''',
- [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
}
test_illegalAsyncReturnType_function_nonFuture() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
int f() async {}
-''',
- [
- StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE,
- HintCode.MISSING_RETURN
- ]);
+''', [
+ StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE,
+ HintCode.MISSING_RETURN
+ ]);
}
test_illegalAsyncReturnType_function_subtypeOfFuture() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
abstract class SubFuture<T> implements Future<T> {}
SubFuture<int> f() async {
return 0;
}
-''',
- [StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE]);
}
test_illegalAsyncReturnType_method_nonFuture() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class C {
int m() async {}
}
-''',
- [
- StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE,
- HintCode.MISSING_RETURN
- ]);
+''', [
+ StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE,
+ HintCode.MISSING_RETURN
+ ]);
}
test_illegalAsyncReturnType_method_subtypeOfFuture() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
abstract class SubFuture<T> implements Future<T> {}
class C {
@@ -563,53 +504,43 @@ class C {
return 0;
}
}
-''',
- [StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE]);
}
test_illegalSyncGeneratorReturnType_function_nonIterator() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
int f() sync* {}
-''',
- [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
test_illegalSyncGeneratorReturnType_function_subclassOfIterator() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
abstract class SubIterator<T> implements Iterator<T> {}
SubIterator<int> f() sync* {}
-''',
- [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
test_illegalSyncGeneratorReturnType_method_nonIterator() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class C {
int f() sync* {}
}
-''',
- [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
test_illegalSyncGeneratorReturnType_method_subclassOfIterator() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
abstract class SubIterator<T> implements Iterator<T> {}
class C {
SubIterator<int> f() sync* {}
}
-''',
- [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
+''', [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
}
test_inconsistentMethodInheritance_paramCount() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
abstract class A {
int x();
}
@@ -617,13 +548,11 @@ abstract class B {
int x(int y);
}
class C implements A, B {
-}''',
- [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
+}''', [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
}
test_inconsistentMethodInheritance_paramType() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
abstract class A {
x(int i);
}
@@ -631,13 +560,11 @@ abstract class B {
x(String s);
}
abstract class C implements A, B {}
-''',
- [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
+''', [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
}
test_inconsistentMethodInheritance_returnType() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
abstract class A {
int x();
}
@@ -645,73 +572,61 @@ abstract class B {
String x();
}
abstract class C implements A, B {}
-''',
- [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
+''', [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
}
test_instanceAccessToStaticMember_method_invocation() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static m() {}
}
main(A a) {
a.m();
-}''',
- [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
+}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
test_instanceAccessToStaticMember_method_reference() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static m() {}
}
main(A a) {
a.m;
-}''',
- [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
+}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
test_instanceAccessToStaticMember_propertyAccess_field() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static var f;
}
main(A a) {
a.f;
-}''',
- [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
+}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
test_instanceAccessToStaticMember_propertyAccess_getter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static get f => 42;
}
main(A a) {
a.f;
-}''',
- [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
+}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
test_instanceAccessToStaticMember_propertyAccess_setter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static set f(x) {}
}
main(A a) {
a.f = 42;
-}''',
- [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
+}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]);
}
test_invalidAssignment_compoundAssignment() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class byte {
int _value;
byte(this._value);
@@ -721,99 +636,80 @@ class byte {
void main() {
byte b = new byte(52);
b += 3;
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_defaultValue_named() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f({String x: 0}) {
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_defaultValue_optional() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f([String x = 0]) {
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_dynamic() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
main() {
dynamic = 1;
}
-''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_functionExpressionInvocation() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
main() {
String x = (() => 5)();
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_ifNullAssignment() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
void f(int i) {
double d;
d ??= i;
}
-''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_instanceVariable() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
int x;
}
f() {
A a;
a.x = '0';
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_localVariable() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
int x;
x = '0';
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_regressionInIssue18468Fix() async {
// https://code.google.com/p/dart/issues/detail?id=18628
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class C<T> {
T t = int;
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_staticVariable() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static int x;
}
f() {
A.x = '0';
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_topLevelVariableDeclaration() async {
@@ -823,35 +719,29 @@ f() {
test_invalidAssignment_typeParameter() async {
// 14221
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class B<T> {
T value;
void test(num n) {
value = n;
}
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invalidAssignment_variableDeclaration() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
int x = 'string';
-}''',
- [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
+}''', [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_invocationOfNonFunction_class() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
void m() {
A();
}
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
test_invocationOfNonFunction_localGenericFunction() async {
@@ -862,39 +752,32 @@ class A {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
resetWith(options: options);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f(Function f) {
return f();
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
test_invocationOfNonFunction_localObject() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
resetWith(options: options);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f(Object o) {
return o();
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
test_invocationOfNonFunction_localVariable() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
int x;
return x();
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
test_invocationOfNonFunction_ordinaryInvocation() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static int x;
}
@@ -902,27 +785,23 @@ class B {
m() {
A.x();
}
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
// A call to verify(source) fails as A.x() cannot be resolved.
}
test_invocationOfNonFunction_staticInvocation() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static int get g => 0;
f() {
A.g();
}
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
// A call to verify(source) fails as g() cannot be resolved.
}
test_invocationOfNonFunction_superExpression() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
int get g => 0;
}
@@ -930,17 +809,14 @@ class B extends A {
m() {
var v = super.g();
}
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
test_invocationOfNonFunctionExpression_literal() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
3(5);
-}''',
- [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION]);
+}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION]);
}
test_nonBoolCondition_conditional() async {
@@ -949,145 +825,115 @@ f() {
}
test_nonBoolCondition_do() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
do {} while (3);
-}''',
- [StaticTypeWarningCode.NON_BOOL_CONDITION]);
+}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
test_nonBoolCondition_for() async {
// https://github.com/dart-lang/sdk/issues/24713
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
for (;3;) {}
-}''',
- [StaticTypeWarningCode.NON_BOOL_CONDITION]);
+}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
test_nonBoolCondition_if() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
if (3) return 2; else return 1;
-}''',
- [StaticTypeWarningCode.NON_BOOL_CONDITION]);
+}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
test_nonBoolCondition_while() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
while (3) {}
-}''',
- [StaticTypeWarningCode.NON_BOOL_CONDITION]);
+}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
test_nonBoolExpression_functionType() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
int makeAssertion() => 1;
f() {
assert(makeAssertion);
-}''',
- [StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
+}''', [StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
}
test_nonBoolExpression_interfaceType() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
assert(0);
-}''',
- [StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
+}''', [StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
}
test_nonBoolNegationExpression() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
f() {
!42;
-}''',
- [StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION]);
+}''', [StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION]);
}
test_nonBoolOperand_and_left() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
bool f(int left, bool right) {
return left && right;
-}''',
- [StaticTypeWarningCode.NON_BOOL_OPERAND]);
+}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
test_nonBoolOperand_and_right() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
bool f(bool left, String right) {
return left && right;
-}''',
- [StaticTypeWarningCode.NON_BOOL_OPERAND]);
+}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
test_nonBoolOperand_or_left() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
bool f(List<int> left, bool right) {
return left || right;
-}''',
- [StaticTypeWarningCode.NON_BOOL_OPERAND]);
+}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
test_nonBoolOperand_or_right() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
bool f(bool left, double right) {
return left || right;
-}''',
- [StaticTypeWarningCode.NON_BOOL_OPERAND]);
+}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]);
}
test_nonTypeAsTypeArgument_notAType() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
int A;
class B<E> {}
-f(B<A> b) {}''',
- [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
+f(B<A> b) {}''', [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
}
test_nonTypeAsTypeArgument_undefinedIdentifier() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class B<E> {}
-f(B<A> b) {}''',
- [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
+f(B<A> b) {}''', [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
}
test_returnOfInvalidType_async_future_int_mismatches_future_string() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
Future<String> f() async {
return 5;
}
-''',
- [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
test_returnOfInvalidType_async_future_int_mismatches_int() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
int f() async {
return 5;
}
-''',
- [
- StaticTypeWarningCode.RETURN_OF_INVALID_TYPE,
- StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE
- ]);
+''', [
+ StaticTypeWarningCode.RETURN_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE
+ ]);
}
test_returnOfInvalidType_expressionFunctionBody_function() async {
@@ -1101,24 +947,20 @@ int f() async {
}
test_returnOfInvalidType_expressionFunctionBody_localFunction() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
String m() {
int f() => '0';
return '0';
}
-}''',
- [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
+}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
test_returnOfInvalidType_expressionFunctionBody_method() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
int f() => '0';
-}''',
- [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
+}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
test_returnOfInvalidType_function() async {
@@ -1132,24 +974,20 @@ class A {
}
test_returnOfInvalidType_localFunction() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
String m() {
int f() { return '0'; }
return '0';
}
-}''',
- [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
+}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
test_returnOfInvalidType_method() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
int f() { return '0'; }
-}''',
- [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
+}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
test_returnOfInvalidType_not_issued_for_expressionFunctionBody_void() async {
@@ -1179,110 +1017,91 @@ void main() { }''');
}
test_typeArgumentNotMatchingBounds_classTypeAlias() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class C {}
class G<E extends A> {}
class D = G<B> with C;
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_extends() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
class C extends G<B>{}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_extends_regressionInIssue18468Fix() async {
// https://code.google.com/p/dart/issues/detail?id=18628
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class X<T extends Type> {}
class Y<U> extends X<U> {}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_fieldFormalParameter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
class C {
var f;
C(G<B> this.f) {}
-}''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+}''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_functionReturnType() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
G<B> f() { return null; }
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_functionTypeAlias() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
typedef G<B> f();
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
f(G<B> h()) {}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_implements() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
class C implements G<B>{}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_is() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
var b = 1 is G<B>;
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_methodInvocation_localFunction() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class Point<T extends num> {
Point(T x, T y);
}
@@ -1293,14 +1112,12 @@ main() {
}
print(f/*<String>*/('hello', 'world'));
}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_methodInvocation_method() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class Point<T extends num> {
Point(T x, T y);
}
@@ -1314,14 +1131,12 @@ class PointFactory {
f(PointFactory factory) {
print(factory.point/*<String>*/('hello', 'world'));
}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_methodInvocation_topLevelFunction() async {
resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class Point<T extends num> {
Point(T x, T y);
}
@@ -1333,189 +1148,155 @@ Point/*<T>*/ f/*<T extends num>*/(num/*=T*/ x, num/*=T*/ y) {
main() {
print(f/*<String>*/('hello', 'world'));
}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_methodReturnType() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
class C {
G<B> m() { return null; }
-}''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+}''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_new() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
f() { return new G<B>(); }
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B extends A {}
class C extends B {}
class G<E extends B> {}
f() { return new G<A>(); }
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_parameter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
f(G<B> g) {}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_redirectingConstructor() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class X<T extends A> {
X(int x, int y) {}
factory X.name(int x, int y) = X<B>;
-}''',
- [
- StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
- StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE
- ]);
+}''', [
+ StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
+ StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE
+ ]);
}
test_typeArgumentNotMatchingBounds_typeArgumentList() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class C<E> {}
class D<E extends A> {}
C<D<B>> Var;
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_typeParameter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class C {}
class G<E extends A> {}
class D<F extends G<B>> {}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_variableDeclaration() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
G<B> g;
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeArgumentNotMatchingBounds_with() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {}
class G<E extends A> {}
class C extends Object with G<B>{}
-''',
- [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
+''', [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
}
test_typeParameterSupertypeOfItsBound() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A<T extends T> {
}
-''',
- [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND]);
+''', [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND]);
}
test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_mutated() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
callMe(f()) { f(); }
main(Object p) {
(p is String) && callMe(() { p.length; });
p = 0;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_booleanAnd_useInRight_mutatedInLeft() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
((p is String) && ((p = 42) == 42)) && p.length != 0;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_booleanAnd_useInRight_mutatedInRight() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
(p is String) && (((p = 42) == 42) && p.length != 0);
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_after() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
callMe(f()) { f(); }
main(Object p) {
p is String ? callMe(() { p.length; }) : 0;
p = 42;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_before() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
callMe(f()) { f(); }
main(Object p) {
p = 42;
p is String ? callMe(() { p.length; }) : 0;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_conditional_useInThen_hasAssignment() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
p is String ? (p.length + (p = 42)) : 0;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_accessedInClosure_hasAssignment() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
callMe(f()) { f(); }
main(Object p) {
if (p is String) {
@@ -1524,24 +1305,20 @@ main(Object p) {
});
}
p = 0;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_and_right_hasAssignment() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
if (p is String && (p = null) == null) {
p.length;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_extends_notMoreSpecific_dynamic() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class V {}
class A<T> {}
class B<S> extends A<S> {
@@ -1552,13 +1329,11 @@ main(A<V> p) {
if (p is B) {
p.b;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_extends_notMoreSpecific_notMoreSpecificTypeArg() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class V {}
class A<T> {}
class B<S> extends A<S> {
@@ -1569,85 +1344,71 @@ main(A<V> p) {
if (p is B<int>) {
p.b;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_hasAssignment_after() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
if (p is String) {
p.length;
p = 0;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_hasAssignment_before() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
if (p is String) {
p = 0;
p.length;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_hasAssignment_inClosure_anonymous_after() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
if (p is String) {
p.length;
}
() {p = 0;};
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_hasAssignment_inClosure_anonymous_before() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
() {p = 0;};
if (p is String) {
p.length;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_hasAssignment_inClosure_function_after() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
if (p is String) {
p.length;
}
f() {p = 0;};
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_hasAssignment_inClosure_function_before() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
main(Object p) {
f() {p = 0;};
if (p is String) {
p.length;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_implements_notMoreSpecific_dynamic() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class V {}
class A<T> {}
class B<S> implements A<S> {
@@ -1658,13 +1419,11 @@ main(A<V> p) {
if (p is B) {
p.b;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_typePromotion_if_with_notMoreSpecific_dynamic() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class V {}
class A<T> {}
class B<S> extends Object with A<S> {
@@ -1675,38 +1434,31 @@ main(A<V> p) {
if (p is B) {
p.b;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedFunction() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
void f() {
g();
-}''',
- [StaticTypeWarningCode.UNDEFINED_FUNCTION]);
+}''', [StaticTypeWarningCode.UNDEFINED_FUNCTION]);
}
test_undefinedFunction_inCatch() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
void f() {
try {
} on Object {
g();
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_FUNCTION]);
+}''', [StaticTypeWarningCode.UNDEFINED_FUNCTION]);
}
test_undefinedFunction_inImportedLib() async {
Source source = addSource(r'''
import 'lib.dart' as f;
main() { return f.g(); }''');
- addNamedSource(
- "/lib.dart",
- r'''
+ addNamedSource("/lib.dart", r'''
library lib;
h() {}''');
await computeAnalysisResult(source);
@@ -1714,11 +1466,9 @@ h() {}''');
}
test_undefinedGetter() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class T {}
-f(T e) { return e.m; }''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+f(T e) { return e.m; }''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_generic_function_call() async {
@@ -1728,31 +1478,26 @@ f(T e) { return e.m; }''',
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
resetWith(options: options);
- await assertErrorsInUnverifiedCode(
- '''
+ await assertErrorsInUnverifiedCode('''
f(Function f) {
return f.call;
}
-''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_object_call() async {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
resetWith(options: options);
- await assertErrorsInUnverifiedCode(
- '''
+ await assertErrorsInUnverifiedCode('''
f(Object o) {
return o.call;
}
-''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_proxy_annotation_fakeProxy() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
library L;
class Fake {
const Fake();
@@ -1761,109 +1506,90 @@ const proxy = const Fake();
@proxy class PrefixProxy {}
main() {
new PrefixProxy().foo;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_static() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
-var a = A.B;''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+var a = A.B;''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_typeLiteral_cascadeTarget() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class T {
static int get foo => 42;
}
main() {
T..foo;
-}''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_typeLiteral_conditionalAccess() async {
// When applied to a type literal, the conditional access operator '?.'
// cannot be used to access instance getters of Type.
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class A {}
f() => A?.hashCode;
-''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_void() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class T {
void m() {}
}
-f(T e) { return e.m().f; }''',
- [StaticTypeWarningCode.UNDEFINED_GETTER]);
+f(T e) { return e.m().f; }''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_wrongNumberOfTypeArguments_tooLittle() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A<K, V> {
K element;
}
main(A<int> a) {
a.element.anyGetterExistsInDynamic;
-}''',
- [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
+}''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
test_undefinedGetter_wrongNumberOfTypeArguments_tooMany() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A<E> {
E element;
}
main(A<int,int> a) {
a.element.anyGetterExistsInDynamic;
-}''',
- [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
+}''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
test_undefinedGetter_wrongOfTypeArgument() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A<E> {
E element;
}
main(A<NoSuchType> a) {
a.element.anyGetterExistsInDynamic;
-}''',
- [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
+}''', [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
}
test_undefinedMethod() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
void m() {
n();
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+}''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_assignmentExpression() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B {
f(A a) {
A a2 = new A();
a += a2;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+}''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_generic_function_call() async {
@@ -1873,18 +1599,15 @@ class B {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
resetWith(options: options);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f(Function f) {
f.call();
}
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_ignoreTypePropagation() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B extends A {
m() {}
@@ -1894,8 +1617,7 @@ class C {
A a = new B();
a.m();
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+}''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_leastUpperBoundWithNull() async {
@@ -1907,50 +1629,41 @@ class C {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.enableStrictCallChecks = true;
resetWith(options: options);
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f(Object o) {
o.call();
}
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_ofNull() async {
// TODO(scheglov) Track https://github.com/dart-lang/sdk/issues/28430 to
// decide whether a warning should be reported here.
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
Null f(int x) => null;
main() {
f(42).abs();
}
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_private() async {
- addNamedSource(
- "/lib.dart",
- r'''
+ addNamedSource("/lib.dart", r'''
library lib;
class A {
_foo() {}
}''');
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
import 'lib.dart';
class B extends A {
test() {
_foo();
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+}''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_proxy_annotation_fakeProxy() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
library L;
class Fake {
const Fake();
@@ -1959,229 +1672,187 @@ const proxy = const Fake();
@proxy class PrefixProxy {}
main() {
new PrefixProxy().foo();
-}''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+}''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_typeLiteral_cascadeTarget() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class T {
static void foo() {}
}
main() {
T..foo();
}
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethod_typeLiteral_conditionalAccess() async {
// When applied to a type literal, the conditional access operator '?.'
// cannot be used to access instance methods of Type.
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
class A {}
f() => A?.toString();
-''',
- [StaticTypeWarningCode.UNDEFINED_METHOD]);
+''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
test_undefinedMethodWithConstructor() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class C {
C.m();
}
f() {
C c = C.m();
-}''',
- [StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR]);
}
test_undefinedOperator_indexBoth() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
f(A a) {
a[0]++;
-}''',
- [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
test_undefinedOperator_indexGetter() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
f(A a) {
a[0];
-}''',
- [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
test_undefinedOperator_indexSetter() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
f(A a) {
a[0] = 1;
-}''',
- [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
test_undefinedOperator_plus() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
f(A a) {
a + 1;
-}''',
- [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
test_undefinedOperator_postfixExpression() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
f(A a) {
a++;
-}''',
- [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
test_undefinedOperator_prefixExpression() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
f(A a) {
++a;
-}''',
- [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
}
test_undefinedSetter() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class T {}
-f(T e1) { e1.m = 0; }''',
- [StaticTypeWarningCode.UNDEFINED_SETTER]);
+f(T e1) { e1.m = 0; }''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
test_undefinedSetter_static() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
-f() { A.B = 0;}''',
- [StaticTypeWarningCode.UNDEFINED_SETTER]);
+f() { A.B = 0;}''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
test_undefinedSetter_typeLiteral_cascadeTarget() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class T {
static void set foo(_) {}
}
main() {
T..foo = 42;
-}''',
- [StaticTypeWarningCode.UNDEFINED_SETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
test_undefinedSetter_void() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class T {
void m() {}
}
-f(T e) { e.m().f = 0; }''',
- [StaticTypeWarningCode.UNDEFINED_SETTER]);
+f(T e) { e.m().f = 0; }''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
test_undefinedSuperGetter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B extends A {
get g {
return super.g;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_SUPER_GETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_SUPER_GETTER]);
}
test_undefinedSuperMethod() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B extends A {
m() { return super.m(); }
-}''',
- [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]);
+}''', [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]);
}
test_undefinedSuperOperator_binaryExpression() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
class B extends A {
operator +(value) {
return super + value;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
test_undefinedSuperOperator_indexBoth() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
class B extends A {
operator [](index) {
return super[index]++;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
test_undefinedSuperOperator_indexGetter() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
class B extends A {
operator [](index) {
return super[index + 1];
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
test_undefinedSuperOperator_indexSetter() async {
- await assertErrorsInUnverifiedCode(
- r'''
+ await assertErrorsInUnverifiedCode(r'''
class A {}
class B extends A {
operator []=(index, value) {
return super[index] = 0;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
+}''', [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]);
}
test_undefinedSuperSetter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class B extends A {
f() {
super.m = 0;
}
-}''',
- [StaticTypeWarningCode.UNDEFINED_SUPER_SETTER]);
+}''', [StaticTypeWarningCode.UNDEFINED_SUPER_SETTER]);
}
test_unqualifiedReferenceToNonLocalStaticMember_getter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static int get a => 0;
}
@@ -2189,15 +1860,11 @@ class B extends A {
int b() {
return a;
}
-}''',
- [
- StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER
- ]);
+}''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]);
}
test_unqualifiedReferenceToNonLocalStaticMember_getter_invokeTarget() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static int foo;
}
@@ -2207,15 +1874,11 @@ class B extends A {
foo.abs();
}
}
-''',
- [
- StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER
- ]);
+''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]);
}
test_unqualifiedReferenceToNonLocalStaticMember_method() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static void a() {}
}
@@ -2223,15 +1886,11 @@ class B extends A {
void b() {
a();
}
-}''',
- [
- StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER
- ]);
+}''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]);
}
test_unqualifiedReferenceToNonLocalStaticMember_setter() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {
static set a(x) {}
}
@@ -2239,15 +1898,11 @@ class B extends A {
b(y) {
a = y;
}
-}''',
- [
- StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER
- ]);
+}''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]);
}
test_wrongNumberOfTypeArguments_classAlias() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class M {}
class B<F extends num> = A<F> with M;''',
@@ -2255,158 +1910,130 @@ class B<F extends num> = A<F> with M;''',
}
test_wrongNumberOfTypeArguments_tooFew() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A<E, F> {}
-A<A> a = null;''',
- [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
+A<A> a = null;''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
test_wrongNumberOfTypeArguments_tooMany() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A<E> {}
-A<A, A> a = null;''',
- [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
+A<A, A> a = null;''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
test_wrongNumberOfTypeArguments_typeTest_tooFew() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class C<K, V> {}
f(p) {
return p is C<A>;
-}''',
- [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
+}''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
test_wrongNumberOfTypeArguments_typeTest_tooMany() async {
- await assertErrorsInCode(
- r'''
+ await assertErrorsInCode(r'''
class A {}
class C<E> {}
f(p) {
return p is C<A, A>;
-}''',
- [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
+}''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
test_yield_async_to_basic_type() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
int f() async* {
yield 3;
}
-''',
- [
- StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
- StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE
- ]);
+''', [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE
+ ]);
}
test_yield_async_to_iterable() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
Iterable<int> f() async* {
yield 3;
}
-''',
- [
- StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
- StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE
- ]);
+''', [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE
+ ]);
}
test_yield_async_to_mistyped_stream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
Stream<int> f() async* {
yield "foo";
}
-''',
- [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
test_yield_each_async_non_stream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f() async* {
yield* 0;
}
-''',
- [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
test_yield_each_async_to_mistyped_stream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
Stream<int> f() async* {
yield* g();
}
Stream<String> g() => null;
-''',
- [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
test_yield_each_sync_non_iterable() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f() sync* {
yield* 0;
}
-''',
- [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
test_yield_each_sync_to_mistyped_iterable() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
Iterable<int> f() sync* {
yield* g();
}
Iterable<String> g() => null;
-''',
- [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
test_yield_sync_to_basic_type() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
int f() sync* {
yield 3;
}
-''',
- [
- StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
- StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
- ]);
+''', [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
+ ]);
}
test_yield_sync_to_mistyped_iterable() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
Iterable<int> f() sync* {
yield "foo";
}
-''',
- [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
}
test_yield_sync_to_stream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
Stream<int> f() sync* {
yield 3;
}
-''',
- [
- StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
- StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
- ]);
+''', [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
+ ]);
}
}
@@ -2440,8 +2067,7 @@ main() {
}
test_legalAsyncGeneratorReturnType_function_supertypeOfStream() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
f() async* { yield 42; }
dynamic f2() async* { yield 42; }
@@ -2451,13 +2077,11 @@ Stream<dynamic> f5() async* { yield 42; }
Stream<Object> f6() async* { yield 42; }
Stream<num> f7() async* { yield 42; }
Stream<int> f8() async* { yield 42; }
-''',
- []);
+''', []);
}
test_legalAsyncReturnType_function_supertypeOfFuture() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
import 'dart:async';
f() async { return 42; }
dynamic f2() async { return 42; }
@@ -2467,13 +2091,11 @@ Future<dynamic> f5() async { return 42; }
Future<Object> f6() async { return 42; }
Future<num> f7() async { return 42; }
Future<int> f8() async { return 42; }
-''',
- []);
+''', []);
}
test_legalSyncGeneratorReturnType_function_supertypeOfIterable() async {
- await assertErrorsInCode(
- '''
+ await assertErrorsInCode('''
f() sync* { yield 42; }
dynamic f2() sync* { yield 42; }
Object f3() sync* { yield 42; }
@@ -2482,7 +2104,6 @@ Iterable<dynamic> f5() sync* { yield 42; }
Iterable<Object> f6() sync* { yield 42; }
Iterable<num> f7() sync* { yield 42; }
Iterable<int> f8() sync* { yield 42; }
-''',
- []);
+''', []);
}
}
« no previous file with comments | « pkg/analyzer/test/generated/source_factory_test.dart ('k') | pkg/analyzer/test/generated/static_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698