From 9789e9d7a061eb90e5cf1b822de704edf691e928 Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Thu, 20 Apr 2023 20:49:17 +0000 Subject: [PATCH] Migrate "e" and "f" 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: Idf9012cb8c213b523d1c8bb827e530e0d2cf6609 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296407 Auto-Submit: Bob Nystrom Reviewed-by: Jake Macdonald Commit-Queue: Bob Nystrom --- .../on_catch_malformed_type_test.dart | 11 +++- .../language/export/ambiguous_main_test.dart | 6 ++- tests/language/factory/factory2_test.dart | 52 +++++++++++++------ tests/language/factory/factory3_test.dart | 33 ++++++++---- tests/language/field/field1_test.dart | 15 ++++-- tests/language/field/field2_test.dart | 12 +++-- tests/language/field/field4_test.dart | 5 +- tests/language/field/field5_test.dart | 5 +- tests/language/field/method4_test.dart | 33 ------------ tests/language/field/override2_test.dart | 4 +- .../language/final/for_in_variable_test.dart | 5 +- .../initializer_instance_reference_test.dart | 8 ++- tests/language/final/is_not_const_test.dart | 6 ++- tests/language/final/param_test.dart | 5 +- .../language/final/super_field_set_test.dart | 5 +- .../on_catch_malformed_type_test.dart | 11 +++- .../export/ambiguous_main_test.dart | 6 ++- tests/language_2/factory/factory2_test.dart | 45 +++++++++++----- tests/language_2/factory/factory3_test.dart | 28 ++++++---- tests/language_2/field/field1_test.dart | 12 ++++- tests/language_2/field/field2_test.dart | 8 ++- tests/language_2/field/field4_test.dart | 5 +- tests/language_2/field/field5_test.dart | 5 +- tests/language_2/field/method4_test.dart | 35 ------------- tests/language_2/field/override2_test.dart | 4 +- .../final/for_in_variable_test.dart | 5 +- .../initializer_instance_reference_test.dart | 8 ++- tests/language_2/final/is_not_const_test.dart | 6 ++- tests/language_2/final/param_test.dart | 5 +- .../final/super_field_set_test.dart | 5 +- 30 files changed, 244 insertions(+), 149 deletions(-) delete mode 100644 tests/language/field/method4_test.dart delete mode 100644 tests/language_2/field/method4_test.dart diff --git a/tests/language/exception/on_catch_malformed_type_test.dart b/tests/language/exception/on_catch_malformed_type_test.dart index 8b49027f719..435d1752431 100644 --- a/tests/language/exception/on_catch_malformed_type_test.dart +++ b/tests/language/exception/on_catch_malformed_type_test.dart @@ -13,7 +13,10 @@ catchUnresolvedBefore() { Expect.fail("This code shouldn't be executed"); } on String catch (oks) { // This is tested before the catch block below. - } on Unavailable catch (ex) { /*@compile-error=unspecified*/ + } on Unavailable catch (ex) { + // ^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE + // [cfe] 'Unavailable' isn't a type. Expect.fail("This code shouldn't be executed"); } } @@ -23,7 +26,11 @@ catchUnresolvedAfter() { try { throw "foo"; Expect.fail("This code shouldn't be executed"); - } on Unavailable catch (ex) { /*@compile-error=unspecified*/ + } on Unavailable catch (ex) { + // ^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE + // [cfe] 'Unavailable' isn't a type. + // This is tested before the catch block below. // In both production and checked mode the test causes a type error. } on String catch (oks) { diff --git a/tests/language/export/ambiguous_main_test.dart b/tests/language/export/ambiguous_main_test.dart index b2a8a24c064..a52cd4fefa8 100644 --- a/tests/language/export/ambiguous_main_test.dart +++ b/tests/language/export/ambiguous_main_test.dart @@ -3,4 +3,8 @@ // BSD-style license that can be found in the LICENSE file. export 'ambiguous_main_a.dart'; -export 'ambiguous_main_b.dart'; /*@compile-error=unspecified*/ +export 'ambiguous_main_b.dart'; +// [error column 1] +// [cfe] 'main' is exported from both 'tests/language/export/ambiguous_main_a.dart' and 'tests/language/export/ambiguous_main_b.dart'. +// ^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXPORT diff --git a/tests/language/factory/factory2_test.dart b/tests/language/factory/factory2_test.dart index f8a2e3a76d5..0ab17784c23 100644 --- a/tests/language/factory/factory2_test.dart +++ b/tests/language/factory/factory2_test.dart @@ -7,19 +7,31 @@ import "dart:collection"; abstract class A { - factory A.create() = AFactory.create; // //# 01: compile-time error + factory A.create() = AFactory.create; + // ^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS + // ^^^^^^^^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_INVALID_RETURN_TYPE + // [cfe] Expected 0 type arguments. } class AFactory { // Compile time error: should be AFactory to match abstract class above - factory A.create() { // //# 01: compile-time error - return null;// //# 01: continued - } // //# 01: continued + factory A.create() { + // ^ + // [analyzer] COMPILE_TIME_ERROR.INVALID_FACTORY_NAME_NOT_A_CLASS + // [cfe] The name of a constructor must match the name of the enclosing class. + throw UnimplementedError(); + } } abstract class Link extends IterableBase { // does not match constructor for LinkFactory - factory Link(T head, [Link tail]) = LinkFactory; //# 03: compile-time error + factory Link(T head, [Link? tail]) = + LinkFactory; +// ^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_INVALID_RETURN_TYPE +// [cfe] The constructor function type 'LinkFactory Function(dynamic, [Link?])' isn't a subtype of 'Link Function(T, [Link?])'. Link prepend(T element); } @@ -28,11 +40,16 @@ abstract class EmptyLink extends Link { } class LinkFactory { - factory LinkFactory(head, [Link tail]) {} + factory LinkFactory(head, [Link? tail]) { + throw UnimplementedError(); + } } // Does not implement all of Iterable -class AbstractLink implements Link { /*@compile-error=unspecified*/ +class AbstractLink implements Link { +// ^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'AbstractLink' is missing implementations for these members: const AbstractLink(); Link prepend(T element) { return new Link(element, this); @@ -40,28 +57,33 @@ class AbstractLink implements Link { /*@compile-error=unspecified*/ } // Does not implement all of Iterable -class LinkTail extends AbstractLink implements EmptyLink { /*@compile-error=unspecified*/ +class LinkTail extends AbstractLink implements EmptyLink { +// ^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkTail' is missing implementations for these members: const LinkTail(); } // Does not implement all of Iterable -class LinkEntry extends AbstractLink { /*@compile-error=unspecified*/ - LinkEntry(T head, Link realTail); +class LinkEntry extends AbstractLink { +// ^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkEntry' is missing implementations for these members: + LinkEntry(T head, Link? realTail); } class Fisk { // instantiation of abstract class - Link nodes = const EmptyLink(); /*@compile-error=unspecified*/ + Link nodes = const EmptyLink(); } main() { // Equivalent to new Link.create(). - var a = new A.create(); // //# none: compile-time error - var a = new A.create(); // //# 01: continued + var a = new A.create(); new Fisk(); // instantiation of abstract class - new EmptyLink().prepend('hest'); //# compile-time error + new EmptyLink().prepend('hest'); // instantiation of abstract class - const EmptyLink().prepend('fisk'); //# compile-time error + const EmptyLink().prepend('fisk'); } diff --git a/tests/language/factory/factory3_test.dart b/tests/language/factory/factory3_test.dart index fe15ad9dae2..e8788cf2072 100644 --- a/tests/language/factory/factory3_test.dart +++ b/tests/language/factory/factory3_test.dart @@ -11,17 +11,20 @@ abstract class A { A.create(); } -abstract class B extends A{} +abstract class B extends A {} // Compile time error: should be AFactory to match abstract class above class AFactory extends B { - factory A.create() { // //# 01: compile-time error - return null; // //# 01: continued - } // //# 01: continued + factory A.create() { + // ^ + // [analyzer] COMPILE_TIME_ERROR.INVALID_FACTORY_NAME_NOT_A_CLASS + // [cfe] The name of a constructor must match the name of the enclosing class. + throw UnimplementedError(); + } } abstract class Link extends IterableBase { - factory Link(T head, [Link tail]) = LinkEntry; + factory Link(T head, [Link? tail]) = LinkEntry; Link prepend(T element); } @@ -29,7 +32,10 @@ abstract class EmptyLink extends Link { const factory EmptyLink() = LinkTail; } -class AbstractLink implements Link { /*@compile-error=unspecified*/ +class AbstractLink implements Link { +// ^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'AbstractLink' is missing implementations for these members: const AbstractLink(); Link prepend(T element) { print("$element"); @@ -40,12 +46,18 @@ class AbstractLink implements Link { /*@compile-error=unspecified*/ } } -class LinkTail extends AbstractLink implements EmptyLink { /*@compile-error=unspecified*/ +class LinkTail extends AbstractLink implements EmptyLink { +// ^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkTail' is missing implementations for these members: const LinkTail(); } -class LinkEntry extends AbstractLink { /*@compile-error=unspecified*/ - LinkEntry(T head, [Link Tail]); +class LinkEntry extends AbstractLink { +// ^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkEntry' is missing implementations for these members: + LinkEntry(T head, [Link? Tail]); } class Fisk { @@ -56,7 +68,6 @@ class Fisk { } main() { - var a = new AFactory.create(); // //# 01: continued - var a = new AFactory.create(); // //# none: compile-time error + var a = new AFactory.create(); new Fisk(0).nodes.prepend(new Fisk(1)).prepend(new Fisk(2)); } diff --git a/tests/language/field/field1_test.dart b/tests/language/field/field1_test.dart index 1591ad141b5..f32b5ca2dbf 100644 --- a/tests/language/field/field1_test.dart +++ b/tests/language/field/field1_test.dart @@ -7,16 +7,25 @@ class C { var a; + // ^ + // [cfe] Conflicts with setter 'a'. - get a {/*@compile-error=unspecified*/ + get a { + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES + // [cfe] 'a' is already declared in this scope. return 1; } - set a(int val) {/*@compile-error=unspecified*/ + set a(int val) { + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] Conflicts with the implicit setter of the field 'a'. var x = val; } - get b { + int get b { return 2; } diff --git a/tests/language/field/field2_test.dart b/tests/language/field/field2_test.dart index a822357bc7d..0d0f75edb00 100644 --- a/tests/language/field/field2_test.dart +++ b/tests/language/field/field2_test.dart @@ -6,15 +6,17 @@ // in the class. class C { - get a { + int get a { return 1; } set a(int val) { + // ^ + // [cfe] Conflicts with the implicit setter of the field 'a'. var x = val; } - get b { + int get b { return 2; } @@ -22,7 +24,11 @@ class C { var x = val; } - var a;/*@compile-error=unspecified*/ + var a; + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] 'a' is already declared in this scope. + // [cfe] Conflicts with setter 'a'. } class Field2Test { diff --git a/tests/language/field/field4_test.dart b/tests/language/field/field4_test.dart index 8c8ef6dcbb6..f86565fdf18 100644 --- a/tests/language/field/field4_test.dart +++ b/tests/language/field/field4_test.dart @@ -9,7 +9,10 @@ class A { return 1; } - var a;/*@compile-error=unspecified*/ + var a; + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] 'a' is already declared in this scope. } class Field4Test { diff --git a/tests/language/field/field5_test.dart b/tests/language/field/field5_test.dart index 943e9bbded7..9719430a2e8 100644 --- a/tests/language/field/field5_test.dart +++ b/tests/language/field/field5_test.dart @@ -6,7 +6,10 @@ class A { var a; - int a() {/*@compile-error=unspecified*/ + int a() { + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] 'a' is already declared in this scope. return 1; } } diff --git a/tests/language/field/method4_test.dart b/tests/language/field/method4_test.dart deleted file mode 100644 index c637241da1b..00000000000 --- a/tests/language/field/method4_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -// Dart test to catch error reporting bugs when using a field like a method. - -class A { - var foo; - A() { - foo = () {}; - } - void bar(var a) { - a.foo();/*@compile-error=unspecified*/ // Tries to invoke the non-existing method 'foo'. - /* - 'a.foo()' is a "Regular instance-method invocation". The guide says: - "If no method is found, the result of the invocation expression is - equivalent to: $0.noSuchMethod(r"id", [$1, ..., $N])." - Invoking noSuchMethod on an instance of A will invoke Object's - noSuchMethod (because A doesn't override that method). Object's - noSuchMethod will throw an error. - */ - } -} - -class FieldMethod4Test { - static testMain() { - var a = new A(); - a.bar();/*@compile-error=unspecified*/ - } -} - -main() { - FieldMethod4Test.testMain(); -} diff --git a/tests/language/field/override2_test.dart b/tests/language/field/override2_test.dart index d37a8ba7374..80840a32330 100644 --- a/tests/language/field/override2_test.dart +++ b/tests/language/field/override2_test.dart @@ -8,12 +8,12 @@ import "package:expect/expect.dart"; class A { - final a = [42]; /*@compile-error=unspecified*/ + final dynamic a = [42]; foo() => a[0]; } class B extends A { - final a = new Map(); + final dynamic a = new Map(); } main() { diff --git a/tests/language/final/for_in_variable_test.dart b/tests/language/final/for_in_variable_test.dart index 0365e6717cc..541b9041d6b 100644 --- a/tests/language/final/for_in_variable_test.dart +++ b/tests/language/final/for_in_variable_test.dart @@ -4,6 +4,9 @@ main() { for (final i in [1, 2, 3]) { - i = 4; /*@compile-error=unspecified*/ + i = 4; +// ^ +// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_LOCAL +// [cfe] Can't assign to the final variable 'i'. } } diff --git a/tests/language/final/initializer_instance_reference_test.dart b/tests/language/final/initializer_instance_reference_test.dart index 1f17dfc5752..be6ea475952 100644 --- a/tests/language/final/initializer_instance_reference_test.dart +++ b/tests/language/final/initializer_instance_reference_test.dart @@ -7,9 +7,15 @@ class C { const C(); +//^^^^^ +// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST final x = 1; - final y = x; /*@compile-error=unspecified*/ + final y = x; + // ^ + // [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER + // [cfe] Can't access 'this' in a field initializer to read 'x'. + // [cfe] Not a constant expression. } main() { diff --git a/tests/language/final/is_not_const_test.dart b/tests/language/final/is_not_const_test.dart index 798b40fd8ce..736ff1c1408 100644 --- a/tests/language/final/is_not_const_test.dart +++ b/tests/language/final/is_not_const_test.dart @@ -5,7 +5,11 @@ import "package:expect/expect.dart"; final F0 = 42; -const C0 = F0; /*@compile-error=unspecified*/ +const C0 = F0; +// ^^ +// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE +// [cfe] Constant evaluation error: +// [cfe] Not a constant expression. main() { Expect.equals(42, F0); diff --git a/tests/language/final/param_test.dart b/tests/language/final/param_test.dart index 197e35719fd..d692526f824 100644 --- a/tests/language/final/param_test.dart +++ b/tests/language/final/param_test.dart @@ -5,7 +5,10 @@ class A { static void test(final x) { - x = 2; /*@compile-error=unspecified*/ + x = 2; +// ^ +// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_LOCAL +// [cfe] Can't assign to the final variable 'x'. } } diff --git a/tests/language/final/super_field_set_test.dart b/tests/language/final/super_field_set_test.dart index 227b2726e52..cc98f0db708 100644 --- a/tests/language/final/super_field_set_test.dart +++ b/tests/language/final/super_field_set_test.dart @@ -9,7 +9,10 @@ class SuperClass { class Class extends SuperClass { m() { - super.field = 87; /*@compile-error=unspecified*/ + super.field = 87; + // ^^^^^ + // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER + // [cfe] Superclass has no setter named 'field'. } } diff --git a/tests/language_2/exception/on_catch_malformed_type_test.dart b/tests/language_2/exception/on_catch_malformed_type_test.dart index 5b91b5ab87d..75a2fd867ff 100644 --- a/tests/language_2/exception/on_catch_malformed_type_test.dart +++ b/tests/language_2/exception/on_catch_malformed_type_test.dart @@ -15,7 +15,10 @@ catchUnresolvedBefore() { Expect.fail("This code shouldn't be executed"); } on String catch (oks) { // This is tested before the catch block below. - } on Unavailable catch (ex) { /*@compile-error=unspecified*/ + } on Unavailable catch (ex) { + // ^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE + // [cfe] 'Unavailable' isn't a type. Expect.fail("This code shouldn't be executed"); } } @@ -25,7 +28,11 @@ catchUnresolvedAfter() { try { throw "foo"; Expect.fail("This code shouldn't be executed"); - } on Unavailable catch (ex) { /*@compile-error=unspecified*/ + } on Unavailable catch (ex) { + // ^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.NON_TYPE_IN_CATCH_CLAUSE + // [cfe] 'Unavailable' isn't a type. + // This is tested before the catch block below. // In both production and checked mode the test causes a type error. } on String catch (oks) { diff --git a/tests/language_2/export/ambiguous_main_test.dart b/tests/language_2/export/ambiguous_main_test.dart index d61ca80ab26..806e162f69f 100644 --- a/tests/language_2/export/ambiguous_main_test.dart +++ b/tests/language_2/export/ambiguous_main_test.dart @@ -5,4 +5,8 @@ // @dart = 2.9 export 'ambiguous_main_a.dart'; -export 'ambiguous_main_b.dart'; /*@compile-error=unspecified*/ +export 'ambiguous_main_b.dart'; +// [error column 1] +// [cfe] 'main' is exported from both 'tests/language_2/export/ambiguous_main_a.dart' and 'tests/language_2/export/ambiguous_main_b.dart'. +// ^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_EXPORT diff --git a/tests/language_2/factory/factory2_test.dart b/tests/language_2/factory/factory2_test.dart index abaeeecd6cb..48c45d0dde0 100644 --- a/tests/language_2/factory/factory2_test.dart +++ b/tests/language_2/factory/factory2_test.dart @@ -9,19 +9,30 @@ import "dart:collection"; abstract class A { - factory A.create() = AFactory.create; // //# 01: compile-time error + factory A.create() = AFactory.create; + // ^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS + // ^^^^^^^^^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_INVALID_RETURN_TYPE + // [cfe] Expected 0 type arguments. } class AFactory { // Compile time error: should be AFactory to match abstract class above - factory A.create() { // //# 01: compile-time error - return null;// //# 01: continued - } // //# 01: continued + factory A.create() { + // ^ + // [analyzer] COMPILE_TIME_ERROR.INVALID_FACTORY_NAME_NOT_A_CLASS + // [cfe] The name of a constructor must match the name of the enclosing class. + } } abstract class Link extends IterableBase { // does not match constructor for LinkFactory - factory Link(T head, [Link tail]) = LinkFactory; //# 03: compile-time error + factory Link(T head, [Link tail]) = + LinkFactory; +// ^^^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_INVALID_RETURN_TYPE +// [cfe] The constructor function type 'LinkFactory Function(dynamic, [Link])' isn't a subtype of 'Link Function(T, [Link])'. Link prepend(T element); } @@ -34,7 +45,10 @@ class LinkFactory { } // Does not implement all of Iterable -class AbstractLink implements Link { /*@compile-error=unspecified*/ +class AbstractLink implements Link { +// ^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'AbstractLink' is missing implementations for these members: const AbstractLink(); Link prepend(T element) { return new Link(element, this); @@ -42,28 +56,33 @@ class AbstractLink implements Link { /*@compile-error=unspecified*/ } // Does not implement all of Iterable -class LinkTail extends AbstractLink implements EmptyLink { /*@compile-error=unspecified*/ +class LinkTail extends AbstractLink implements EmptyLink { +// ^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkTail' is missing implementations for these members: const LinkTail(); } // Does not implement all of Iterable -class LinkEntry extends AbstractLink { /*@compile-error=unspecified*/ +class LinkEntry extends AbstractLink { +// ^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkEntry' is missing implementations for these members: LinkEntry(T head, Link realTail); } class Fisk { // instantiation of abstract class - Link nodes = const EmptyLink(); /*@compile-error=unspecified*/ + Link nodes = const EmptyLink(); } main() { // Equivalent to new Link.create(). - var a = new A.create(); // //# none: compile-time error - var a = new A.create(); // //# 01: continued + var a = new A.create(); new Fisk(); // instantiation of abstract class - new EmptyLink().prepend('hest'); //# compile-time error + new EmptyLink().prepend('hest'); // instantiation of abstract class - const EmptyLink().prepend('fisk'); //# compile-time error + const EmptyLink().prepend('fisk'); } diff --git a/tests/language_2/factory/factory3_test.dart b/tests/language_2/factory/factory3_test.dart index dc9d4cc312e..d5f0313b64b 100644 --- a/tests/language_2/factory/factory3_test.dart +++ b/tests/language_2/factory/factory3_test.dart @@ -13,13 +13,15 @@ abstract class A { A.create(); } -abstract class B extends A{} +abstract class B extends A {} // Compile time error: should be AFactory to match abstract class above class AFactory extends B { - factory A.create() { // //# 01: compile-time error - return null; // //# 01: continued - } // //# 01: continued + factory A.create() { + // ^ + // [analyzer] COMPILE_TIME_ERROR.INVALID_FACTORY_NAME_NOT_A_CLASS + // [cfe] The name of a constructor must match the name of the enclosing class. + } } abstract class Link extends IterableBase { @@ -31,7 +33,10 @@ abstract class EmptyLink extends Link { const factory EmptyLink() = LinkTail; } -class AbstractLink implements Link { /*@compile-error=unspecified*/ +class AbstractLink implements Link { +// ^^^^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'AbstractLink' is missing implementations for these members: const AbstractLink(); Link prepend(T element) { print("$element"); @@ -42,11 +47,17 @@ class AbstractLink implements Link { /*@compile-error=unspecified*/ } } -class LinkTail extends AbstractLink implements EmptyLink { /*@compile-error=unspecified*/ +class LinkTail extends AbstractLink implements EmptyLink { +// ^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkTail' is missing implementations for these members: const LinkTail(); } -class LinkEntry extends AbstractLink { /*@compile-error=unspecified*/ +class LinkEntry extends AbstractLink { +// ^^^^^^^^^ +// [analyzer] COMPILE_TIME_ERROR.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER +// [cfe] The non-abstract class 'LinkEntry' is missing implementations for these members: LinkEntry(T head, [Link Tail]); } @@ -58,7 +69,6 @@ class Fisk { } main() { - var a = new AFactory.create(); // //# 01: continued - var a = new AFactory.create(); // //# none: compile-time error + var a = new AFactory.create(); new Fisk(0).nodes.prepend(new Fisk(1)).prepend(new Fisk(2)); } diff --git a/tests/language_2/field/field1_test.dart b/tests/language_2/field/field1_test.dart index 07d48180f50..6969d7e9b83 100644 --- a/tests/language_2/field/field1_test.dart +++ b/tests/language_2/field/field1_test.dart @@ -9,12 +9,20 @@ class C { var a; + // ^ + // [cfe] Conflicts with setter 'a'. - get a {/*@compile-error=unspecified*/ + get a { + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] 'a' is already declared in this scope. return 1; } - set a(int val) {/*@compile-error=unspecified*/ + set a(int val) { + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] Conflicts with the implicit setter of the field 'a'. var x = val; } diff --git a/tests/language_2/field/field2_test.dart b/tests/language_2/field/field2_test.dart index a7baf4d0edf..679e48e918d 100644 --- a/tests/language_2/field/field2_test.dart +++ b/tests/language_2/field/field2_test.dart @@ -13,6 +13,8 @@ class C { } set a(int val) { + // ^ + // [cfe] Conflicts with the implicit setter of the field 'a'. var x = val; } @@ -24,7 +26,11 @@ class C { var x = val; } - var a;/*@compile-error=unspecified*/ + var a; + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] 'a' is already declared in this scope. + // [cfe] Conflicts with setter 'a'. } class Field2Test { diff --git a/tests/language_2/field/field4_test.dart b/tests/language_2/field/field4_test.dart index fbe06102c45..85517e4b7d1 100644 --- a/tests/language_2/field/field4_test.dart +++ b/tests/language_2/field/field4_test.dart @@ -11,7 +11,10 @@ class A { return 1; } - var a;/*@compile-error=unspecified*/ + var a; + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] 'a' is already declared in this scope. } class Field4Test { diff --git a/tests/language_2/field/field5_test.dart b/tests/language_2/field/field5_test.dart index 4002322098f..f8f0b9d3451 100644 --- a/tests/language_2/field/field5_test.dart +++ b/tests/language_2/field/field5_test.dart @@ -8,7 +8,10 @@ class A { var a; - int a() {/*@compile-error=unspecified*/ + int a() { + // ^ + // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION + // [cfe] 'a' is already declared in this scope. return 1; } } diff --git a/tests/language_2/field/method4_test.dart b/tests/language_2/field/method4_test.dart deleted file mode 100644 index 9b961431fe3..00000000000 --- a/tests/language_2/field/method4_test.dart +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -// Dart test to catch error reporting bugs when using a field like a method. - -// @dart = 2.9 - -class A { - var foo; - A() { - foo = () {}; - } - void bar(var a) { - a.foo();/*@compile-error=unspecified*/ // Tries to invoke the non-existing method 'foo'. - /* - 'a.foo()' is a "Regular instance-method invocation". The guide says: - "If no method is found, the result of the invocation expression is - equivalent to: $0.noSuchMethod(r"id", [$1, ..., $N])." - Invoking noSuchMethod on an instance of A will invoke Object's - noSuchMethod (because A doesn't override that method). Object's - noSuchMethod will throw an error. - */ - } -} - -class FieldMethod4Test { - static testMain() { - var a = new A(); - a.bar();/*@compile-error=unspecified*/ - } -} - -main() { - FieldMethod4Test.testMain(); -} diff --git a/tests/language_2/field/override2_test.dart b/tests/language_2/field/override2_test.dart index 5aacd1d6f76..29c666a4aee 100644 --- a/tests/language_2/field/override2_test.dart +++ b/tests/language_2/field/override2_test.dart @@ -10,12 +10,12 @@ import "package:expect/expect.dart"; class A { - final a = [42]; /*@compile-error=unspecified*/ + final dynamic a = [42]; foo() => a[0]; } class B extends A { - final a = new Map(); + final dynamic a = new Map(); } main() { diff --git a/tests/language_2/final/for_in_variable_test.dart b/tests/language_2/final/for_in_variable_test.dart index 8c5899d813f..7fb8aa63ac6 100644 --- a/tests/language_2/final/for_in_variable_test.dart +++ b/tests/language_2/final/for_in_variable_test.dart @@ -6,6 +6,9 @@ main() { for (final i in [1, 2, 3]) { - i = 4; /*@compile-error=unspecified*/ + i = 4; +// ^ +// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_LOCAL +// [cfe] Can't assign to the final variable 'i'. } } diff --git a/tests/language_2/final/initializer_instance_reference_test.dart b/tests/language_2/final/initializer_instance_reference_test.dart index e61652eecae..be02d1ec0a6 100644 --- a/tests/language_2/final/initializer_instance_reference_test.dart +++ b/tests/language_2/final/initializer_instance_reference_test.dart @@ -9,9 +9,15 @@ class C { const C(); +//^^^^^ +// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST final x = 1; - final y = x; /*@compile-error=unspecified*/ + final y = x; + // ^ + // [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER + // [cfe] Can't access 'this' in a field initializer to read 'x'. + // [cfe] Not a constant expression. } main() { diff --git a/tests/language_2/final/is_not_const_test.dart b/tests/language_2/final/is_not_const_test.dart index dae899e3df7..e00c708980a 100644 --- a/tests/language_2/final/is_not_const_test.dart +++ b/tests/language_2/final/is_not_const_test.dart @@ -7,7 +7,11 @@ import "package:expect/expect.dart"; final F0 = 42; -const C0 = F0; /*@compile-error=unspecified*/ +const C0 = F0; +// ^^ +// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE +// [cfe] Constant evaluation error: +// [cfe] Not a constant expression. main() { Expect.equals(42, F0); diff --git a/tests/language_2/final/param_test.dart b/tests/language_2/final/param_test.dart index 2bf807efa87..3711e780c4d 100644 --- a/tests/language_2/final/param_test.dart +++ b/tests/language_2/final/param_test.dart @@ -7,7 +7,10 @@ class A { static void test(final x) { - x = 2; /*@compile-error=unspecified*/ + x = 2; +// ^ +// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_LOCAL +// [cfe] Can't assign to the final variable 'x'. } } diff --git a/tests/language_2/final/super_field_set_test.dart b/tests/language_2/final/super_field_set_test.dart index 765cbb306e7..8cd8156637f 100644 --- a/tests/language_2/final/super_field_set_test.dart +++ b/tests/language_2/final/super_field_set_test.dart @@ -11,7 +11,10 @@ class SuperClass { class Class extends SuperClass { m() { - super.field = 87; /*@compile-error=unspecified*/ + super.field = 87; + // ^^^^^ + // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER + // [cfe] Superclass has no setter named 'field'. } }