mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
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 <rnystrom@google.com> Reviewed-by: Jake Macdonald <jakemac@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
829958d387
commit
9789e9d7a0
30 changed files with 244 additions and 149 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,19 +7,31 @@
|
|||
import "dart:collection";
|
||||
|
||||
abstract class A<T> {
|
||||
factory A.create() = AFactory<T>.create; // //# 01: compile-time error
|
||||
factory A.create() = AFactory<T>.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<T> 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<T> extends IterableBase<T> {
|
||||
// does not match constructor for LinkFactory
|
||||
factory Link(T head, [Link<T> tail]) = LinkFactory<T>; //# 03: compile-time error
|
||||
factory Link(T head, [Link<T>? tail]) =
|
||||
LinkFactory<T>;
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_INVALID_RETURN_TYPE
|
||||
// [cfe] The constructor function type 'LinkFactory<T> Function(dynamic, [Link<dynamic>?])' isn't a subtype of 'Link<T> Function(T, [Link<T>?])'.
|
||||
Link<T> prepend(T element);
|
||||
}
|
||||
|
||||
|
@ -28,11 +40,16 @@ abstract class EmptyLink<T> extends Link<T> {
|
|||
}
|
||||
|
||||
class LinkFactory<T> {
|
||||
factory LinkFactory(head, [Link tail]) {}
|
||||
factory LinkFactory(head, [Link? tail]) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
// Does not implement all of Iterable
|
||||
class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
||||
class AbstractLink<T> implements Link<T> {
|
||||
// ^^^^^^^^^^^^
|
||||
// [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<T> prepend(T element) {
|
||||
return new Link<T>(element, this);
|
||||
|
@ -40,28 +57,33 @@ class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
|||
}
|
||||
|
||||
// Does not implement all of Iterable
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> { /*@compile-error=unspecified*/
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> {
|
||||
// ^^^^^^^^
|
||||
// [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<T> extends AbstractLink<T> { /*@compile-error=unspecified*/
|
||||
LinkEntry(T head, Link<T> realTail);
|
||||
class LinkEntry<T> extends AbstractLink<T> {
|
||||
// ^^^^^^^^^
|
||||
// [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<T>? realTail);
|
||||
}
|
||||
|
||||
class Fisk {
|
||||
// instantiation of abstract class
|
||||
Link<String> nodes = const EmptyLink(); /*@compile-error=unspecified*/
|
||||
Link<String> nodes = const EmptyLink();
|
||||
}
|
||||
|
||||
main() {
|
||||
// Equivalent to new Link<dynamic>.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<String>().prepend('hest'); //# compile-time error
|
||||
new EmptyLink<String>().prepend('hest');
|
||||
// instantiation of abstract class
|
||||
const EmptyLink<String>().prepend('fisk'); //# compile-time error
|
||||
const EmptyLink<String>().prepend('fisk');
|
||||
}
|
||||
|
|
|
@ -11,17 +11,20 @@ abstract class A<T> {
|
|||
A.create();
|
||||
}
|
||||
|
||||
abstract class B<T> extends A<T>{}
|
||||
abstract class B<T> extends A<T> {}
|
||||
|
||||
// Compile time error: should be AFactory<T> to match abstract class above
|
||||
class AFactory extends B<int> {
|
||||
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<T> extends IterableBase<T> {
|
||||
factory Link(T head, [Link<T> tail]) = LinkEntry<T>;
|
||||
factory Link(T head, [Link<T>? tail]) = LinkEntry<T>;
|
||||
Link<T> prepend(T element);
|
||||
}
|
||||
|
||||
|
@ -29,7 +32,10 @@ abstract class EmptyLink<T> extends Link<T> {
|
|||
const factory EmptyLink() = LinkTail<T>;
|
||||
}
|
||||
|
||||
class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
||||
class AbstractLink<T> implements Link<T> {
|
||||
// ^^^^^^^^^^^^
|
||||
// [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<T> prepend(T element) {
|
||||
print("$element");
|
||||
|
@ -40,12 +46,18 @@ class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
|||
}
|
||||
}
|
||||
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> { /*@compile-error=unspecified*/
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> {
|
||||
// ^^^^^^^^
|
||||
// [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<T> extends AbstractLink<T> { /*@compile-error=unspecified*/
|
||||
LinkEntry(T head, [Link<T> Tail]);
|
||||
class LinkEntry<T> extends AbstractLink<T> {
|
||||
// ^^^^^^^^^
|
||||
// [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<T>? 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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -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'.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,19 +9,30 @@
|
|||
import "dart:collection";
|
||||
|
||||
abstract class A<T> {
|
||||
factory A.create() = AFactory<T>.create; // //# 01: compile-time error
|
||||
factory A.create() = AFactory<T>.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<T> 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<T> extends IterableBase<T> {
|
||||
// does not match constructor for LinkFactory
|
||||
factory Link(T head, [Link<T> tail]) = LinkFactory<T>; //# 03: compile-time error
|
||||
factory Link(T head, [Link<T> tail]) =
|
||||
LinkFactory<T>;
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_INVALID_RETURN_TYPE
|
||||
// [cfe] The constructor function type 'LinkFactory<T> Function(dynamic, [Link<dynamic>])' isn't a subtype of 'Link<T> Function(T, [Link<T>])'.
|
||||
Link<T> prepend(T element);
|
||||
}
|
||||
|
||||
|
@ -34,7 +45,10 @@ class LinkFactory<T> {
|
|||
}
|
||||
|
||||
// Does not implement all of Iterable
|
||||
class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
||||
class AbstractLink<T> implements Link<T> {
|
||||
// ^^^^^^^^^^^^
|
||||
// [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<T> prepend(T element) {
|
||||
return new Link<T>(element, this);
|
||||
|
@ -42,28 +56,33 @@ class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
|||
}
|
||||
|
||||
// Does not implement all of Iterable
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> { /*@compile-error=unspecified*/
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> {
|
||||
// ^^^^^^^^
|
||||
// [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<T> extends AbstractLink<T> { /*@compile-error=unspecified*/
|
||||
class LinkEntry<T> extends AbstractLink<T> {
|
||||
// ^^^^^^^^^
|
||||
// [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<T> realTail);
|
||||
}
|
||||
|
||||
class Fisk {
|
||||
// instantiation of abstract class
|
||||
Link<String> nodes = const EmptyLink(); /*@compile-error=unspecified*/
|
||||
Link<String> nodes = const EmptyLink();
|
||||
}
|
||||
|
||||
main() {
|
||||
// Equivalent to new Link<dynamic>.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<String>().prepend('hest'); //# compile-time error
|
||||
new EmptyLink<String>().prepend('hest');
|
||||
// instantiation of abstract class
|
||||
const EmptyLink<String>().prepend('fisk'); //# compile-time error
|
||||
const EmptyLink<String>().prepend('fisk');
|
||||
}
|
||||
|
|
|
@ -13,13 +13,15 @@ abstract class A<T> {
|
|||
A.create();
|
||||
}
|
||||
|
||||
abstract class B<T> extends A<T>{}
|
||||
abstract class B<T> extends A<T> {}
|
||||
|
||||
// Compile time error: should be AFactory<T> to match abstract class above
|
||||
class AFactory extends B<int> {
|
||||
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<T> extends IterableBase<T> {
|
||||
|
@ -31,7 +33,10 @@ abstract class EmptyLink<T> extends Link<T> {
|
|||
const factory EmptyLink() = LinkTail<T>;
|
||||
}
|
||||
|
||||
class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
||||
class AbstractLink<T> implements Link<T> {
|
||||
// ^^^^^^^^^^^^
|
||||
// [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<T> prepend(T element) {
|
||||
print("$element");
|
||||
|
@ -42,11 +47,17 @@ class AbstractLink<T> implements Link<T> { /*@compile-error=unspecified*/
|
|||
}
|
||||
}
|
||||
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> { /*@compile-error=unspecified*/
|
||||
class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> {
|
||||
// ^^^^^^^^
|
||||
// [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<T> extends AbstractLink<T> { /*@compile-error=unspecified*/
|
||||
class LinkEntry<T> extends AbstractLink<T> {
|
||||
// ^^^^^^^^^
|
||||
// [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<T> 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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -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'.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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'.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue