Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5f8b3e8

Browse files
nshahanCommit Bot
authored andcommitted
[tests] Migrate multi-test to static error test
Remove compile time errors from null_test.dart and move them into a new static error test file. Add the other mixin application syntax. This makes it so much easier to run and debug null_test.dart on a backend. Change-Id: I126a580ccf477962cd90dccff267034bd9b35a2b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254722 Commit-Queue: Erik Ernst <[email protected]> Auto-Submit: Nicholas Shahan <[email protected]> Reviewed-by: Erik Ernst <[email protected]>
1 parent 66038b7 commit 5f8b3e8

File tree

4 files changed

+72
-16
lines changed

4 files changed

+72
-16
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
class BadExtends extends Null {}
6+
// ^^^^
7+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
8+
// ^
9+
// [cfe] 'Null' is restricted and can't be extended or implemented.
10+
// [cfe] The superclass, 'Null', has no unnamed constructor that takes no arguments.
11+
// ^
12+
// [cfe] 'Null' is restricted and can't be extended or implemented.
13+
14+
class BadImplements implements Null {}
15+
// ^^^^
16+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
17+
// ^
18+
// [cfe] 'Null' is restricted and can't be extended or implemented.
19+
// ^
20+
// [cfe] 'Null' is restricted and can't be extended or implemented.
21+
22+
class BadMixin extends Object with Null {}
23+
// ^^^^
24+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
25+
// ^
26+
// [cfe] 'Null' is restricted and can't be extended or implemented.
27+
// ^
28+
// [cfe] 'Null' is restricted and can't be extended or implemented.
29+
30+
class BadMixin2 = Object with Null;
31+
// ^^^^
32+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
33+
// ^
34+
// [cfe] 'Null' is restricted and can't be extended or implemented.
35+
// ^
36+
// [cfe] 'Null' is restricted and can't be extended or implemented.

tests/language/null/null_test.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77

88
import "package:expect/expect.dart";
99

10-
class BadInherit
11-
extends Null // //# 01: compile-time error
12-
implements Null // //# 02: compile-time error
13-
extends Object with Null // //# 03: compile-time error
14-
{}
15-
1610
class EqualsNotCalled {
1711
int get hashCode => throw "And don't warn!";
1812
bool operator ==(Object other) {
@@ -52,8 +46,6 @@ void main() {
5246
}
5347

5448
void test() {
55-
new BadInherit(); // Make sure class is referenced.
56-
5749
void foo(var obj) {
5850
Expect.equals(null, obj);
5951
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
class BadExtends extends Null {}
6+
// ^^^^
7+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
8+
// ^
9+
// [cfe] 'Null' is restricted and can't be extended or implemented.
10+
// [cfe] The superclass, 'Null', has no unnamed constructor that takes no arguments.
11+
// ^
12+
// [cfe] 'Null' is restricted and can't be extended or implemented.
13+
14+
class BadImplements implements Null {}
15+
// ^^^^
16+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
17+
// ^
18+
// [cfe] 'Null' is restricted and can't be extended or implemented.
19+
// ^
20+
// [cfe] 'Null' is restricted and can't be extended or implemented.
21+
22+
class BadMixin extends Object with Null {}
23+
// ^^^^
24+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
25+
// ^
26+
// [cfe] 'Null' is restricted and can't be extended or implemented.
27+
// ^
28+
// [cfe] 'Null' is restricted and can't be extended or implemented.
29+
30+
class BadMixin2 = Object with Null;
31+
// ^^^^
32+
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DISALLOWED_TYPE
33+
// ^
34+
// [cfe] 'Null' is restricted and can't be extended or implemented.
35+
// ^
36+
// [cfe] 'Null' is restricted and can't be extended or implemented.

tests/language_2/null/null_test.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
import "package:expect/expect.dart";
1111

12-
class BadInherit
13-
extends Null // //# 01: compile-time error
14-
implements Null // //# 02: compile-time error
15-
extends Object with Null // //# 03: compile-time error
16-
{}
17-
1812
class EqualsNotCalled {
1913
int get hashCode => throw "And don't warn!";
2014
bool operator ==(Object other) {
@@ -54,8 +48,6 @@ void main() {
5448
}
5549

5650
void test() {
57-
new BadInherit(); // Make sure class is referenced.
58-
5951
int foo(var obj) {
6052
Expect.equals(null, obj);
6153
}

0 commit comments

Comments
 (0)