Migrate "l" and "m" directory language tests off @compile-error.

The "@compile-error" comment is an old not-great way of defining static
error tests.

Also fix a test to use a mixin declaration instead of a class for declaring a mixin. This was
broken by class modifiers but the breakage was masked by @compile-error treating a test as
passing if any compile error, even an unrelated one, is reported.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I5d1d387002d886cb87340e2559bf8ed01c3f2d6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296409
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This commit is contained in:
Robert Nystrom 2023-04-20 17:51:42 +00:00 committed by Commit Queue
parent 9bdd2ff1de
commit 924b9f55ba
35 changed files with 201 additions and 52 deletions

View file

@ -6,5 +6,8 @@
main() {
var chars = [];
for (var c in "foo") chars.add(c); /*@compile-error=unspecified*/
for (var c in "foo") chars.add(c);
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.FOR_IN_OF_INVALID_TYPE
// [cfe] The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
}

View file

@ -4,4 +4,9 @@
main() {}
var main; /*@compile-error=unspecified*/
var main;
// ^^^^
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
// [analyzer] COMPILE_TIME_ERROR.MAIN_IS_NOT_FUNCTION
// [cfe] 'main' is already declared in this scope.
// [cfe] The 'main' declaration must be a function declaration.

View file

@ -8,7 +8,11 @@ class A<T extends num> {}
class B<T> {
test() {
new A() as A<T>; /*@compile-error=unspecified*/
new A() as A<T>;
// ^
// [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'A'.
// ^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
}

View file

@ -3,7 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
null_() => null;
final Undeclared/*@compile-error=unspecified*/ x = null_();
final Undeclared x = null_();
// ^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] 'Undeclared' isn't a type.
// [cfe] Type 'Undeclared' not found.
main() {
print(x);

View file

@ -10,11 +10,14 @@ class A {
A() : field = 2;
}
class Mixin {}
mixin Mixin {}
class B extends A with Mixin {}
main() {
Expect.equals(2, new B().field);
new B.bar(); /*@compile-error=unspecified*/
new B.bar();
// ^^^
// [analyzer] COMPILE_TIME_ERROR.NEW_WITH_UNDEFINED_CONSTRUCTOR
// [cfe] Couldn't find constructor 'B.bar'.
}

View file

@ -11,6 +11,11 @@ mixin M0<T> on I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends I with M0<int> {} /*@compile-error=unspecified*/
class A00 extends I with M0<int> {}
// ^
// [cfe] 'I with M0' can't implement both 'I<dynamic>' and 'I<int>'
// [cfe] 'I<dynamic>' doesn't implement 'I<int>' so it can't be used with 'M0<int>'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
void main() {}
void main() {}

View file

@ -13,6 +13,11 @@ mixin M1<T> on I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends I with M0, M1<int> {} /*@compile-error=unspecified*/
class A00 extends I with M0, M1<int> {}
// ^
// [cfe] 'I with M0, M1' can't implement both 'I<dynamic>' and 'I<int>'
// [cfe] '_A00&I&M0' doesn't implement 'I<int>' so it can't be used with 'M1<int>'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
void main() {}
void main() {}

View file

@ -13,6 +13,11 @@ mixin M1<T> on I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 with M0, M1<int> {} /*@compile-error=unspecified*/
class A00 with M0, M1<int> {}
// ^
// [cfe] 'Object with M0, M1' can't implement both 'I<dynamic>' and 'I<int>'
// [cfe] '_A00&Object&M0' doesn't implement 'I<int>' so it can't be used with 'M1<int>'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
void main() {}
void main() {}

View file

@ -11,6 +11,9 @@ mixin M0<T> implements I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends Object with M0 implements I<int> {} /*@compile-error=unspecified*/
class A00 extends Object with M0 implements I<int> {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'A00' can't implement both 'I<dynamic>' and 'I<int>'
void main() {}
void main() {}

View file

@ -11,6 +11,9 @@ mixin M0<T> implements I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 with M0 implements I<int> {} /*@compile-error=unspecified*/
class A00 with M0 implements I<int> {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'A00' can't implement both 'I<dynamic>' and 'I<int>'
void main() {}
void main() {}

View file

@ -13,6 +13,9 @@ mixin M1<T> implements I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends I<int> with M0<int>, M1 {} /*@compile-error=unspecified*/
class A00 extends I<int> with M0<int>, M1 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'I with M0, M1' can't implement both 'I<int>' and 'I<dynamic>'
void main() {}
void main() {}

View file

@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
class I<X> {}
class J<X> {}
mixin M0<S, T> implements I<S>, J<T> {}
@ -14,10 +15,21 @@ mixin M1<S, T> implements I<S>, J<T> {}
///////////////////////////////////////////////////////
class A00 extends I<int> with M0 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'I with M0' can't implement both 'I<int>' and 'I<dynamic>'
class A01 extends J<int> with M1 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'J with M1' can't implement both 'J<int>' and 'J<dynamic>'
// Error since class hierarchy is inconsistent
class A02 extends A00 implements A01 {} /*@compile-error=unspecified*/
class A02 extends A00 implements A01 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'A02' can't implement both 'I<int>' and 'I<dynamic>'
// [cfe] 'A02' can't implement both 'J<dynamic>' and 'J<int>'
void main() {}
void main() {}

View file

@ -14,6 +14,9 @@ class M1 implements I<int> {}
// M0 is inferred as M0<int, Comparable<dynamic>>
// Error since super-bounded type not allowed
class A extends M1 with M0 {} /*@compile-error=unspecified*/
class A extends M1 with M0 {}
// ^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
// [cfe] Inferred type argument 'Comparable<dynamic>' doesn't conform to the bound 'Comparable<Y>' of the type variable 'Y' on 'M0'.
void main() {}
void main() {}

View file

@ -12,10 +12,12 @@ mixin M1<T> implements I<String, T> {}
// Inference is not bi-directional
///////////////////////////////////////////////////////
// M0<String>, M1<int> is a solution, but we shouldn't find it
// M0 inferred as M0<dynamic>
// M1 inferred as M1<dynamic>
class A with M0, M1 {} /*@compile-error=unspecified*/
class A with M0, M1 {}
// ^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'Object with M0, M1' can't implement both 'I<dynamic, int>' and 'I<String, dynamic>'
void main() {}
void main() {}

View file

@ -18,6 +18,9 @@ mixin M1<T> implements I<List<T>, T> {}
// U0 = List<U1>
// U1 = List<U0>
// which has no finite solution
class A with M0, M1 {} /*@compile-error=unspecified*/
class A with M0, M1 {}
// ^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'Object with M0, M1' can't implement both 'I<dynamic, List<dynamic>>' and 'I<List<dynamic>, dynamic>'
void main() {}
void main() {}

View file

@ -2,14 +2,21 @@
// 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.
class I<T> {}
class J<T> {}
mixin I<T> {}
mixin J<T> {}
mixin M0<T> implements I<T>, J<T> {}
//////////////////////////////////////////////////////
// Over-constrained results are caught
///////////////////////////////////////////////////////
class A with I<int>, J<double>, M0 {} /*@compile-error=unspecified*/
class A with I<int>, J<double>, M0 {}
// ^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'Object with I, J, M0' can't implement both 'I<int>' and 'I<dynamic>'
// [cfe] 'Object with I, J, M0' can't implement both 'J<double>' and 'J<dynamic>'
void main() {}
void main() {}

View file

@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
class I<T> {}
mixin M1<T> on I<T> {}
//////////////////////////////////////////////////////
@ -10,6 +11,9 @@ mixin M1<T> on I<T> {}
// the "on" clause of a mixin
///////////////////////////////////////////////////////
mixin A00Mixin on I<int>, M1 {} /*@compile-error=unspecified*/
mixin A00Mixin on I<int>, M1 {}
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'I with M1' can't implement both 'I<int>' and 'I<dynamic>'
void main() {}
void main() {}

View file

@ -18,5 +18,8 @@ class B extends A with Mixin {}
main() {
Expect.equals(2, new B().field);
new B.bar(); /*@compile-error=unspecified*/
new B.bar();
// ^^^
// [analyzer] COMPILE_TIME_ERROR.NEW_WITH_UNDEFINED_CONSTRUCTOR
// [cfe] Couldn't find constructor 'B.bar'.
}

View file

@ -8,5 +8,8 @@
main() {
var chars = [];
for (var c in "foo") chars.add(c); /*@compile-error=unspecified*/
for (var c in "foo") chars.add(c);
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.FOR_IN_OF_INVALID_TYPE
// [cfe] The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
}

View file

@ -6,4 +6,7 @@
main() {}
var main; /*@compile-error=unspecified*/
var main;
// ^^^^
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
// [cfe] 'main' is already declared in this scope.

View file

@ -10,7 +10,11 @@ class A<T extends num> {}
class B<T> {
test() {
new A() as A<T>; /*@compile-error=unspecified*/
new A() as A<T>;
// ^
// [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'A'.
// ^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
}

View file

@ -5,7 +5,11 @@
// @dart = 2.9
null_() => null;
final Undeclared/*@compile-error=unspecified*/ x = null_();
final Undeclared x = null_();
// ^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
// [cfe] 'Undeclared' isn't a type.
// [cfe] Type 'Undeclared' not found.
main() {
print(x);

View file

@ -18,5 +18,8 @@ class B extends A with Mixin {}
main() {
Expect.equals(2, new B().field);
new B.bar(); /*@compile-error=unspecified*/
new B.bar();
// ^^^
// [analyzer] COMPILE_TIME_ERROR.NEW_WITH_UNDEFINED_CONSTRUCTOR
// [cfe] Couldn't find constructor 'B.bar'.
}

View file

@ -13,6 +13,11 @@ mixin M0<T> on I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends I with M0<int> {} /*@compile-error=unspecified*/
class A00 extends I with M0<int> {}
// ^
// [cfe] 'I with M0' can't implement both 'I<dynamic>' and 'I<int>'
// [cfe] 'I<dynamic>' doesn't implement 'I<int>' so it can't be used with 'M0<int>'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
void main() {}

View file

@ -15,6 +15,11 @@ mixin M1<T> on I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends I with M0, M1<int> {} /*@compile-error=unspecified*/
class A00 extends I with M0, M1<int> {}
// ^
// [cfe] 'I with M0, M1' can't implement both 'I<dynamic>' and 'I<int>'
// [cfe] '_A00&I&M0' doesn't implement 'I<int>' so it can't be used with 'M1<int>'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
void main() {}

View file

@ -15,6 +15,11 @@ mixin M1<T> on I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 with M0, M1<int> {} /*@compile-error=unspecified*/
class A00 with M0, M1<int> {}
// ^
// [cfe] 'Object with M0, M1' can't implement both 'I<dynamic>' and 'I<int>'
// [cfe] '_A00&Object&M0' doesn't implement 'I<int>' so it can't be used with 'M1<int>'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
void main() {}

View file

@ -13,6 +13,9 @@ mixin M0<T> implements I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends Object with M0 implements I<int> {} /*@compile-error=unspecified*/
class A00 extends Object with M0 implements I<int> {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'A00' can't implement both 'I<dynamic>' and 'I<int>'
void main() {}

View file

@ -13,6 +13,9 @@ mixin M0<T> implements I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 with M0 implements I<int> {} /*@compile-error=unspecified*/
class A00 with M0 implements I<int> {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'A00' can't implement both 'I<dynamic>' and 'I<int>'
void main() {}

View file

@ -15,6 +15,9 @@ mixin M1<T> implements I<T> {}
///////////////////////////////////////////////////////
// Error since class hierarchy is inconsistent
class A00 extends I<int> with M0<int>, M1 {} /*@compile-error=unspecified*/
class A00 extends I<int> with M0<int>, M1 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'I with M0, M1' can't implement both 'I<int>' and 'I<dynamic>'
void main() {}

View file

@ -5,6 +5,7 @@
// @dart = 2.9
class I<X> {}
class J<X> {}
mixin M0<S, T> implements I<S>, J<T> {}
@ -16,10 +17,21 @@ mixin M1<S, T> implements I<S>, J<T> {}
///////////////////////////////////////////////////////
class A00 extends I<int> with M0 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'I with M0' can't implement both 'I<int>' and 'I<dynamic>'
class A01 extends J<int> with M1 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'J with M1' can't implement both 'J<int>' and 'J<dynamic>'
// Error since class hierarchy is inconsistent
class A02 extends A00 implements A01 {} /*@compile-error=unspecified*/
class A02 extends A00 implements A01 {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'A02' can't implement both 'I<int>' and 'I<dynamic>'
// [cfe] 'A02' can't implement both 'J<dynamic>' and 'J<int>'
void main() {}

View file

@ -16,6 +16,9 @@ class M1 implements I<int> {}
// M0 is inferred as M0<int, Comparable<dynamic>>
// Error since super-bounded type not allowed
class A extends M1 with M0 {} /*@compile-error=unspecified*/
class A extends M1 with M0 {}
// ^^
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
// [cfe] Inferred type argument 'Comparable<dynamic>' doesn't conform to the bound 'Comparable<Y>' of the type variable 'Y' on 'M0'.
void main() {}

View file

@ -14,10 +14,12 @@ mixin M1<T> implements I<String, T> {}
// Inference is not bi-directional
///////////////////////////////////////////////////////
// M0<String>, M1<int> is a solution, but we shouldn't find it
// M0 inferred as M0<dynamic>
// M1 inferred as M1<dynamic>
class A with M0, M1 {} /*@compile-error=unspecified*/
class A with M0, M1 {}
// ^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'Object with M0, M1' can't implement both 'I<dynamic, int>' and 'I<String, dynamic>'
void main() {}

View file

@ -20,6 +20,9 @@ mixin M1<T> implements I<List<T>, T> {}
// U0 = List<U1>
// U1 = List<U0>
// which has no finite solution
class A with M0, M1 {} /*@compile-error=unspecified*/
class A with M0, M1 {}
// ^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'Object with M0, M1' can't implement both 'I<dynamic, List<dynamic>>' and 'I<List<dynamic>, dynamic>'
void main() {}

View file

@ -5,13 +5,20 @@
// @dart = 2.9
class I<T> {}
class J<T> {}
mixin M0<T> implements I<T>, J<T> {}
//////////////////////////////////////////////////////
// Over-constrained results are caught
///////////////////////////////////////////////////////
class A with I<int>, J<double>, M0 {} /*@compile-error=unspecified*/
class A with I<int>, J<double>, M0 {}
// ^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'Object with I, J, M0' can't implement both 'I<int>' and 'I<dynamic>'
// [cfe] 'Object with I, J, M0' can't implement both 'J<double>' and 'J<dynamic>'
void main() {}

View file

@ -5,6 +5,7 @@
// @dart = 2.9
class I<T> {}
mixin M1<T> on I<T> {}
//////////////////////////////////////////////////////
@ -12,6 +13,9 @@ mixin M1<T> on I<T> {}
// the "on" clause of a mixin
///////////////////////////////////////////////////////
mixin A00Mixin on I<int>, M1 {} /*@compile-error=unspecified*/
mixin A00Mixin on I<int>, M1 {}
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_GENERIC_INTERFACES
// [cfe] 'I with M1' can't implement both 'I<int>' and 'I<dynamic>'
void main() {}