Migrate "a" 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: I35d4a7c7ad09cb77ff379af036180794d8b6afbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296403
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Robert Nystrom 2023-04-20 20:50:39 +00:00 committed by Commit Queue
parent 9789e9d7a0
commit 9bb4402abd
10 changed files with 50 additions and 10 deletions

View file

@ -12,5 +12,8 @@ abstract class A {
}
void main() {
/*@compile-error=unspecified*/ new A();
new A();
// ^
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
// [cfe] The class 'A' is abstract and can't be instantiated.
}

View file

@ -14,7 +14,11 @@ abstract class B extends A {
void foo([x]);
}
class /*@compile-error=unspecified*/ C extends B {
class C extends B {
// ^
// [analyzer] COMPILE_TIME_ERROR.INVALID_IMPLEMENTATION_OVERRIDE
// [cfe] The implementation of 'foo' in the non-abstract class 'C' does not conform to its interface.
// However, there is a problem here because this class is concrete and doesn't
// override foo.
}

View file

@ -7,9 +7,13 @@ class A {
}
class B extends A {
// ^
// [analyzer] COMPILE_TIME_ERROR.INVALID_IMPLEMENTATION_OVERRIDE
// [cfe] The implementation of 'foo' in the non-abstract class 'B' does not conform to its interface.
// This class declaration violates soundness, since it allows `new
// B().foo(42)`, which would lead to invalid arguments being passed to A.foo.
void /*@compile-error=unspecified*/ foo([x]);
void foo([x]);
}
void f(B b) {

View file

@ -18,7 +18,11 @@ class C extends B {
void foo([x]) {
// But it is a problem to try to pass `x` along to super, since the super
// method is A.foo.
super.foo(/*@compile-error=unspecified*/ x);
super.foo(x);
// ^
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
}
}

View file

@ -10,5 +10,10 @@ method() {
main() {
// Illegal, can't change a top level method
/*@compile-error=unspecified*/ method = () { return 1; };
method = () {
//^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FUNCTION
// [cfe] Setter not found: 'method'.
return 1;
};
}

View file

@ -14,5 +14,8 @@ abstract class A {
}
void main() {
/*@compile-error=unspecified*/ new A();
new A();
// ^
// [analyzer] COMPILE_TIME_ERROR.INSTANTIATE_ABSTRACT_CLASS
// [cfe] The class 'A' is abstract and can't be instantiated.
}

View file

@ -16,7 +16,11 @@ abstract class B extends A {
void foo([x]);
}
class /*@compile-error=unspecified*/ C extends B {
class C extends B {
// ^
// [analyzer] COMPILE_TIME_ERROR.INVALID_IMPLEMENTATION_OVERRIDE
// [cfe] The implementation of 'foo' in the non-abstract class 'C' does not conform to its interface.
// However, there is a problem here because this class is concrete and doesn't
// override foo.
}

View file

@ -9,9 +9,13 @@ class A {
}
class B extends A {
// ^
// [analyzer] COMPILE_TIME_ERROR.INVALID_IMPLEMENTATION_OVERRIDE
// [cfe] The implementation of 'foo' in the non-abstract class 'B' does not conform to its interface.
// This class declaration violates soundness, since it allows `new
// B().foo(42)`, which would lead to invalid arguments being passed to A.foo.
void /*@compile-error=unspecified*/ foo([x]);
void foo([x]);
}
void f(B b) {

View file

@ -20,7 +20,11 @@ class C extends B {
void foo([x]) {
// But it is a problem to try to pass `x` along to super, since the super
// method is A.foo.
super.foo(/*@compile-error=unspecified*/ x);
super.foo(x);
// ^
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
}
}

View file

@ -12,5 +12,10 @@ method() {
main() {
// Illegal, can't change a top level method
/*@compile-error=unspecified*/ method = () { return 1; };
method = () {
//^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FUNCTION
// [cfe] Setter not found: 'method'.
return 1;
};
}