mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
Migrate "t" directory language tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static error tests. See: https://github.com/dart-lang/sdk/issues/45634 Change-Id: I4c2840deffe5d790a22facebbcc8a02c1cb98020 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296425 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Nate Bosch <nbosch@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
199feac353
commit
51fe275a62
|
@ -13,7 +13,10 @@ int get getter {
|
|||
|
||||
class Class {
|
||||
method() {
|
||||
getter++; /*@compile-error=unspecified*/
|
||||
getter++;
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@ final int getter = () {
|
|||
|
||||
class Class {
|
||||
method() {
|
||||
getter++; /*@compile-error=unspecified*/
|
||||
getter++;
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
// Test that an unresolved method call at the top level creates a compile-
|
||||
// time error.
|
||||
|
||||
var a = b(); /*@compile-error=unspecified*/
|
||||
var a = b();
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_FUNCTION
|
||||
// [cfe] Method not found: 'b'.
|
||||
|
||||
main() {
|
||||
print(a);
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
// Test that an unresolved identifier at the top level causes a compile-time
|
||||
// error.
|
||||
|
||||
var a = b; /*@compile-error=unspecified*/
|
||||
var a = b;
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
|
||||
// [cfe] Undefined name 'b'.
|
||||
|
||||
main() {
|
||||
print(a);
|
||||
|
|
|
@ -15,7 +15,11 @@ class A {
|
|||
|
||||
int foo(String x) => 499;
|
||||
|
||||
const a = const A(foo); /*@compile-error=unspecified*/
|
||||
const a = const A(foo);
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
|
||||
// [cfe] The argument type 'int Function(String)' can't be assigned to the parameter type 'String Function(int)'.
|
||||
|
||||
main() {
|
||||
a.f(499);
|
||||
|
|
|
@ -10,10 +10,14 @@ abstract class J<T> {}
|
|||
|
||||
abstract class I<T extends num> {}
|
||||
|
||||
class A</*@compile-error=unspecified*/T> implements I<T>, J<T> {}
|
||||
class A<T> implements I<T>, J<T> {}
|
||||
// ^
|
||||
// [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'I'.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
// We are only interested in the instance creation, hence
|
||||
// the result is assigned to `dynamic`.
|
||||
dynamic a = /*@compile-error=unspecified*/ new A<String>();
|
||||
dynamic a = new A<String>();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@ class A {
|
|||
|
||||
class B<T> {
|
||||
doFunc() {
|
||||
T.func(); /*@compile-error=unspecified*/
|
||||
T.func();
|
||||
//^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
|
||||
// [cfe] The method 'func' isn't defined for the class 'Type'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
class Foo<T> {
|
||||
// T is not in scope for a static method.
|
||||
static Foo<T> m() { /*@compile-error=unspecified*/
|
||||
static Foo<T> m() {
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_PARAMETER_REFERENCED_BY_STATIC
|
||||
// [cfe] Type variables can't be used in static members.
|
||||
return new Foo();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,16 @@
|
|||
|
||||
class A<T> {
|
||||
static int method() {
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.BODY_MIGHT_COMPLETE_NORMALLY
|
||||
// [cfe] A non-null value must be returned since the return type 'int' doesn't allow null.
|
||||
|
||||
// error, can't reference a type variable in a static context
|
||||
var foo =
|
||||
new T(); /*@compile-error=unspecified*/
|
||||
var foo = new T();
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CREATION_WITH_NON_TYPE
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_PARAMETER_REFERENCED_BY_STATIC
|
||||
// [cfe] Couldn't find constructor 'T'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
typedef F<T extends num> = T Function<U>(T x);
|
||||
|
||||
void g(/*@compile-error=unspecified*/ F<String>? f) {}
|
||||
void g(F<String>? f) {}
|
||||
// ^
|
||||
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'F'.
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
g(null);
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
typedef T F<T extends num>(T x);
|
||||
|
||||
void g(/*@compile-error=unspecified*/ F<String>? f) {}
|
||||
void g(F<String>? f) {}
|
||||
// ^
|
||||
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'F'.
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
g(null);
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
|
||||
typedef void F<T extends num>();
|
||||
|
||||
void g(/*@compile-error=unspecified*/ F<String>? f) {}
|
||||
void g(F<String>? f) {}
|
||||
// ^
|
||||
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'F'.
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
g(null);
|
||||
|
|
|
@ -14,7 +14,10 @@ int get getter {
|
|||
|
||||
class Class {
|
||||
method() {
|
||||
getter++; /*@compile-error=unspecified*/
|
||||
getter++;
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@ final int getter = () {
|
|||
|
||||
class Class {
|
||||
method() {
|
||||
getter++; /*@compile-error=unspecified*/
|
||||
getter++;
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
// Test that an unresolved method call at the top level creates a compile-
|
||||
// time error.
|
||||
|
||||
var a = b(); /*@compile-error=unspecified*/
|
||||
var a = b();
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_FUNCTION
|
||||
// [cfe] Method not found: 'b'.
|
||||
|
||||
main() {
|
||||
print(a);
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
// Test that an unresolved identifier at the top level causes a compile-time
|
||||
// error.
|
||||
|
||||
var a = b; /*@compile-error=unspecified*/
|
||||
var a = b;
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
|
||||
// [cfe] Undefined name 'b'.
|
||||
|
||||
main() {
|
||||
print(a);
|
||||
|
|
|
@ -17,7 +17,11 @@ class A {
|
|||
|
||||
int foo(String x) => 499;
|
||||
|
||||
const a = const A(foo); /*@compile-error=unspecified*/
|
||||
const a = const A(foo);
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
|
||||
// [cfe] The argument type 'int Function(String)' can't be assigned to the parameter type 'String Function(int)'.
|
||||
|
||||
main() {
|
||||
a.f(499);
|
||||
|
|
|
@ -12,10 +12,14 @@ abstract class J<T> {}
|
|||
|
||||
abstract class I<T extends num> {}
|
||||
|
||||
class A</*@compile-error=unspecified*/T> implements I<T>, J<T> {}
|
||||
class A<T> implements I<T>, J<T> {}
|
||||
// ^
|
||||
// [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'I'.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
// We are only interested in the instance creation, hence
|
||||
// the result is assigned to `dynamic`.
|
||||
dynamic a = /*@compile-error=unspecified*/ new A<String>();
|
||||
dynamic a = new A<String>();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,10 @@ class A {
|
|||
|
||||
class B<T> {
|
||||
doFunc() {
|
||||
T.func(); /*@compile-error=unspecified*/
|
||||
T.func();
|
||||
//^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
|
||||
// [cfe] The method 'func' isn't defined for the class 'Type'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
class Foo<T> {
|
||||
// T is not in scope for a static method.
|
||||
static Foo<T> m() { /*@compile-error=unspecified*/
|
||||
static Foo<T> m() {
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_PARAMETER_REFERENCED_BY_STATIC
|
||||
// [cfe] Type variables can't be used in static members.
|
||||
return new Foo();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,11 @@
|
|||
class A<T> {
|
||||
static int method() {
|
||||
// error, can't reference a type variable in a static context
|
||||
var foo =
|
||||
new T(); /*@compile-error=unspecified*/
|
||||
var foo = new T();
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CREATION_WITH_NON_TYPE
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_PARAMETER_REFERENCED_BY_STATIC
|
||||
// [cfe] Couldn't find constructor 'T'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
|
||||
typedef F<T extends num> = T Function<U>(T x);
|
||||
|
||||
void g(/*@compile-error=unspecified*/ F<String> f) {}
|
||||
void g(F<String> f) {}
|
||||
// ^
|
||||
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'F'.
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
g(null);
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
|
||||
typedef T F<T extends num>(T x);
|
||||
|
||||
void g(/*@compile-error=unspecified*/ F<String> f) {}
|
||||
void g(F<String> f) {}
|
||||
// ^
|
||||
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'F'.
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
g(null);
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
typedef void F<T extends num>();
|
||||
|
||||
void g(/*@compile-error=unspecified*/ F<String> f) {}
|
||||
void g(F<String> f) {}
|
||||
// ^
|
||||
// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'F'.
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
|
||||
|
||||
main() {
|
||||
g(null);
|
||||
|
|
Loading…
Reference in a new issue