Remove unnecessary leftover @dart=2.19 from tests.

Change-Id: I6d5e15ff2d432202618fbc490969a65a9181816d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396281
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
This commit is contained in:
Lasse R.H. Nielsen
2024-11-28 09:10:30 +00:00
committed by Commit Queue
parent dbc9c86f05
commit 5430e68680
215 changed files with 4650 additions and 1882 deletions
+13 -1
View File
@@ -17,7 +17,7 @@ Object? context<T>(T x) => x;
T contextType<T>(Object? result) => result as T;
extension StaticType<T> on T {
/// Check the static type.
/// Check the static type against another type wrt. sub- and supertype.
///
/// Use as follows (assuming `e` has static type `num`):
/// ```dart
@@ -45,6 +45,18 @@ extension StaticType<T> on T {
callback<T>();
return this;
}
/// The static type as a `Type` object.
///
/// Can be used for doing "same type" equality checks, like
/// ```dart
/// Expect(typeOf<int Function(int)>(), value.functionName.staticType);
/// ```
/// The [Type.operator==] distinguishes some types that are equivalent
/// wrt. super- and sub-typing, like `dynamic` and `Object?`.
/// It also performs normalization, so `typeOf<FutureOr<Object>> == Object`,
/// even if they differ as static types.
Type get staticType => T;
}
/// Invokes [callback] with the static type of [value].
+2 -1
View File
@@ -64,6 +64,8 @@ abstract class _TestFileBase {
/// The parsed error expectation markers in this test, if it is a static
/// error test.
///
/// If empty, the test is not a static error test.
final List<StaticError> expectedErrors;
/// The name of the multitest section this file corresponds to if it was
@@ -358,7 +360,6 @@ class TestFile extends _TestFileBase {
result
.addAll(_parseExpectations(uriString, alreadyParsed: alreadyParsed));
}
return result;
}
+66 -12
View File
@@ -19,7 +19,6 @@ foo1(int a) async {
case 2:
k += a;
return k + 2;
default: k = 2; //# withDefault: ok
}
return k;
}
@@ -34,7 +33,6 @@ foo2(Future<int> a) async {
case 2:
k += await a;
return k + 2;
default: k = 2; //# withDefault: ok
}
return k;
}
@@ -48,7 +46,6 @@ foo3(int a) async {
case 2:
k += a;
return k + 2;
default: k = 2; //# withDefault: ok
}
return k;
}
@@ -62,7 +59,64 @@ foo4(value) async {
case 2:
k += 2;
return 2 + k;
default: k = 2; //# withDefault: ok
}
return k;
}
foo1WithDefault(int a) async {
int k = 0;
switch (a) {
case 1:
await 3;
k += 1;
break;
case 2:
k += a;
return k + 2;
default: k = 2;
}
return k;
}
foo2WithDefault(Future<int> a) async {
int k = 0;
switch (await a) {
case 1:
await 3;
k += 1;
break;
case 2:
k += await a;
return k + 2;
default: k = 2;
}
return k;
}
foo3WithDefault(int a) async {
int k = 0;
switch (a) {
case 1:
k += 1;
break;
case 2:
k += a;
return k + 2;
default: k = 2;
}
return k;
}
foo4WithDefault(value) async {
int k = 0;
switch (await value) {
case 1:
k += 1;
break;
case 2:
k += 2;
return 2 + k;
default: k = 2;
}
return k;
}
@@ -72,20 +126,20 @@ Future<int> futureOf(int a) async => await a;
Future test() async {
Expect.equals(1, await foo1(1));
Expect.equals(4, await foo1(2));
Expect.equals(2, await foo1(3)); //# withDefault: ok
Expect.equals(0, await foo1(3)); //# none: ok
Expect.equals(2, await foo1WithDefault(3));
Expect.equals(0, await foo1(3));
Expect.equals(1, await foo2(futureOf(1)));
Expect.equals(4, await foo2(futureOf(2)));
Expect.equals(2, await foo2(futureOf(3))); //# withDefault: ok
Expect.equals(0, await foo2(futureOf(3))); //# none: ok
Expect.equals(2, await foo2WithDefault(futureOf(3)));
Expect.equals(0, await foo2(futureOf(3)));
Expect.equals(1, await foo3(1));
Expect.equals(4, await foo3(2));
Expect.equals(2, await foo3(3)); //# withDefault: ok
Expect.equals(0, await foo3(3)); //# none: ok
Expect.equals(2, await foo3WithDefault(3));
Expect.equals(0, await foo3(3));
Expect.equals(1, await foo4(futureOf(1)));
Expect.equals(4, await foo4(futureOf(2)));
Expect.equals(2, await foo4(futureOf(3))); //# withDefault: ok
Expect.equals(0, await foo4(futureOf(3))); //# none: ok
Expect.equals(2, await foo4WithDefault(futureOf(3)));
Expect.equals(0, await foo4(futureOf(3)));
}
void main() {
@@ -0,0 +1,39 @@
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class B {}
class C {
B call(B b) => b;
}
class D implements Function {
B call(B b) => b;
}
typedef B BToB(B x);
typedef Object NullToObject(Null x);
main() {
// The presence of a `.call` method does not cause class `C` to become a
// subtype of any function type.
C c = new C();
Expect.throwsTypeError(() => c as BToB); //# 01: ok
Expect.throwsTypeError(() => c as NullToObject); //# 02: ok
Expect.throwsTypeError(() => c as Function); //# 03: ok
// The same goes for class `D`: `implements Function` is ignored in Dart 2.
D d = new D();
Expect.throwsTypeError(() => d as BToB); //# 04: ok
Expect.throwsTypeError(() => d as NullToObject); //# 05: ok
Expect.throwsTypeError(() => d as Function); //# 06: ok
}
+1 -4
View File
@@ -2,9 +2,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -15,7 +12,7 @@ class C {
B call(B b) => b;
}
class D implements Function {
class D {
B call(B b) => b;
}
@@ -0,0 +1,57 @@
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
class D {
C1 c1 = new C1();
dynamic d1 = new C1();
C2 c2 = new C2();
dynamic d2 = new C2();
void test() {
// Implicitly invokes c1.call(1)
Expect.equals(c1(1), 2); //# 01: ok
// Implicitly invokes d1.call(1)
Expect.equals(d1(1), 2); //# 02: ok
// Implicitly invokes c2.call(1)
Expect.equals(c2(1), 2); //# 03: ok
// Implicitly invokes d2.call(1)
Expect.equals(d2(1), 2); //# 04: ok
}
}
main() {
new D().test();
// Implicitly invokes D.c1.call(1)
Expect.equals(new D().c1(1), 2); //# 05: ok
// Implicitly invokes D.d1.call(1)
Expect.equals(new D().d1(1), 2); //# 06: ok
// Implicitly invokes D.c2.call(1)
Expect.equals(new D().c2(1), 2); //# 07: ok
// Implicitly invokes D.d2.call(1)
Expect.equals(new D().d2(1), 2); //# 08: ok
D d = new D();
// Implicitly invokes d.c1.call(1)
Expect.equals(d.c1(1), 2); //# 09: ok
// Implicitly invokes d.d1.call(1)
Expect.equals(d.d1(1), 2); //# 10: ok
// Implicitly invokes d.c2.call(1)
Expect.equals(d.c2(1), 2); //# 11: ok
// Implicitly invokes d.d2.call(1)
Expect.equals(d.d2(1), 2); //# 12: ok
}
@@ -2,9 +2,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -13,7 +10,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -0,0 +1,44 @@
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
Expect.equals(c1(1), 2);
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
Expect.equals(d1(1), 2);
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
Expect.equals(c2(1), 2);
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
Expect.equals(d2(1), 2);
// Cannot invoke with the wrong signature.
c2();
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
//^^
// [cfe] Too few positional arguments: 1 required, 0 given.
c2(3, 4);
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
//^^^^^^
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
}
@@ -0,0 +1,39 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
Expect.equals(c1(1), 2);
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
// Cannot invoke with the wrong signature.
}
@@ -5,9 +5,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -16,7 +13,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -0,0 +1,39 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
Expect.equals(d1(1), 2);
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
// Cannot invoke with the wrong signature.
}
@@ -5,9 +5,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -16,7 +13,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -0,0 +1,39 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
Expect.equals(c2(1), 2);
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
// Cannot invoke with the wrong signature.
}
@@ -5,9 +5,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -16,7 +13,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -0,0 +1,39 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
Expect.equals(d2(1), 2);
// Cannot invoke with the wrong signature.
}
@@ -5,9 +5,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -16,7 +13,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -0,0 +1,39 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2018, 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
// Cannot invoke with the wrong signature.
}
@@ -5,9 +5,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -16,7 +13,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -2,9 +2,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -13,10 +10,6 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
int call(int i) => 2 * i;
}
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
@@ -24,19 +17,13 @@ main() {
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
Expect.equals(d1(1), 2);
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
Expect.equals(c2(1), 2);
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
Expect.equals(d2(1), 2);
// Cannot invoke with the wrong signature.
c2();
c1();
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
//^^
// [cfe] Too few positional arguments: 1 required, 0 given.
c2(3, 4);
c1(3, 4);
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
//^^^^^^
@@ -2,9 +2,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -13,7 +10,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -2,9 +2,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -13,7 +10,7 @@ class C1 {
int call(int i) => 2 * i;
}
class C2 implements Function {
class C2 {
int call(int i) => 2 * i;
}
@@ -2,9 +2,6 @@
// 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.
// Implements Function which is not allowed in Dart 3.
// @dart=2.19
// Dart test program to test arithmetic operations.
import "package:expect/expect.dart";
@@ -15,7 +12,7 @@ class C {
B call(B b) => b;
}
class D implements Function {
class D {
B call(B b) => b;
}
@@ -0,0 +1,56 @@
// Copyright (c) 2021, 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=2.19
import 'package:expect/expect.dart';
/// Returns its argument.
///
/// Prevents static optimizations and inlining.
@pragma('vm:never-inline')
@pragma('dart2js:noInline')
dynamic getValueNonOptimized(dynamic x) {
// DateTime.now() cannot be predicted statically, never equal to 42.
if (DateTime.now().millisecondsSinceEpoch == 42) {
return getValueNonOptimized(2);
}
return x;
}
class MyClass {
final int n;
const MyClass(this.n);
int get hashCode => super.hashCode + 1;
}
main() {
const constInstance = MyClass(1);
final nonConstInstance = MyClass(1);
const constMap = {MyClass(1): 11};
final nonConstMap = {constInstance: 11};
final nonConstMap2 = {nonConstInstance: 11};
// operator== is _not_ overridden, so instances are not equal.
Expect.notEquals(constInstance, nonConstInstance);
Expect.isTrue(constMap.containsKey(getValueNonOptimized(constInstance)));
Expect.isFalse(constMap.containsKey(getValueNonOptimized(nonConstInstance)));
Expect.isTrue(nonConstMap.containsKey(getValueNonOptimized(constInstance)));
Expect.isFalse(
nonConstMap.containsKey(getValueNonOptimized(nonConstInstance)));
Expect.isFalse(nonConstMap2.containsKey(getValueNonOptimized(constInstance)));
Expect.isTrue(
nonConstMap2.containsKey(getValueNonOptimized(nonConstInstance)));
Expect.equals(11, constMap[getValueNonOptimized(constInstance)]);
Expect.isNull(constMap[getValueNonOptimized(nonConstInstance)]);
Expect.equals(11, nonConstMap[getValueNonOptimized(constInstance)]);
Expect.isNull(nonConstMap[getValueNonOptimized(nonConstInstance)]);
Expect.isNull(nonConstMap2[getValueNonOptimized(constInstance)]);
Expect.equals(11, nonConstMap2[getValueNonOptimized(nonConstInstance)]);
}
@@ -1,7 +1,9 @@
// Copyright (c) 2021, 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.
//
// Checks that a const map can have a key which overrides `hashCode`.
// Overriding `hashCode` in const map keys was made an error in Dart 3.0.
// @dart=2.19
import 'package:expect/expect.dart';
@@ -0,0 +1,43 @@
// Copyright (c) 2021, 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=2.19
import 'package:expect/expect.dart';
/// Returns its argument.
///
/// Prevents static optimizations and inlining.
@pragma('vm:never-inline')
@pragma('dart2js:noInline')
dynamic getValueNonOptimized(dynamic x) {
// DateTime.now() cannot be predicted statically, never equal to 42.
if (DateTime.now().millisecondsSinceEpoch == 42) {
return getValueNonOptimized(2);
}
return x;
}
class Nasty {
final int n;
const Nasty(this.n);
int get hashCode {
throw "Evil hashCode";
}
}
main() {
// Test that when using an instance of a custom class as a key in a const Map,
// its hash code is computed as its identity hash, and even if the class
// overrides `hashCode`, that `hashCode` implementation is not called.
final map = const {1: 42, 'foo': 499, 2: 'bar', Nasty(1): 'baz'};
Expect.equals(42, map[getValueNonOptimized(1.0)]);
Expect.equals(
499, map[getValueNonOptimized(new String.fromCharCodes('foo'.runes))]);
Expect.equals('bar', map[getValueNonOptimized(2)]);
Expect.isNull(map[getValueNonOptimized(Nasty(1))]);
Expect.equals('baz', map[getValueNonOptimized(const Nasty(1))]);
}
@@ -1,7 +1,10 @@
// Copyright (c) 2021, 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.
//
// Checks what happens if a const map can has a key which overrides `hashCode`
// in a nasty way.
// Overriding `hashCode` in const map keys was made an error in Dart 3.0.
// @dart=2.19
import 'package:expect/expect.dart';
@@ -0,0 +1,47 @@
// Copyright (c) 2021, 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=2.19
import 'package:expect/expect.dart';
/// Returns its argument.
///
/// Prevents static optimizations and inlining.
@pragma('vm:never-inline')
@pragma('dart2js:noInline')
dynamic getValueNonOptimized(dynamic x) {
// DateTime.now() cannot be predicted statically, never equal to 42.
if (DateTime.now().millisecondsSinceEpoch == 42) {
return getValueNonOptimized(2);
}
return x;
}
class MyClass {
final int n;
const MyClass(this.n);
int get hashCode => super.hashCode + 1;
}
main() {
const constInstance = MyClass(1);
final nonConstInstance = MyClass(1);
const constSet = {MyClass(1)};
final nonConstSet = {constInstance};
final nonConstSet2 = {nonConstInstance};
// operator== is _not_ overridden, so instances are not equal.
Expect.notEquals(constInstance, nonConstInstance);
Expect.isTrue(constSet.contains(getValueNonOptimized(constInstance)));
Expect.isFalse(constSet.contains(getValueNonOptimized(nonConstInstance)));
Expect.isTrue(nonConstSet.contains(getValueNonOptimized(constInstance)));
Expect.isFalse(nonConstSet.contains(getValueNonOptimized(nonConstInstance)));
Expect.isFalse(nonConstSet2.contains(getValueNonOptimized(constInstance)));
Expect.isTrue(nonConstSet2.contains(getValueNonOptimized(nonConstInstance)));
}
@@ -1,7 +1,8 @@
// Copyright (c) 2021, 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.
//
// Overriding `hashCode` in const set elements was made an error in Dart 3.0.
// @dart=2.19
import 'package:expect/expect.dart';
@@ -0,0 +1,26 @@
// Copyright (c) 2014, 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=2.19
import 'package:expect/expect.dart';
void main() {
var a = [1, 2, 3][2];
switch (a) {
case 0.0:
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
// ^
// [cfe] Type 'double' of the case expression is not a subtype of type 'int' of this switch expression.
// ^
// [cfe] Case expression '0.0' does not have a primitive operator '=='.
print("illegal");
break;
case 1:
print("OK");
}
}
+1
View File
@@ -2,6 +2,7 @@
// 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.
//
// Tests pre-pattern legacy behavior.
// @dart=2.19
import 'package:expect/expect.dart';
@@ -2,11 +2,6 @@
// 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.
// TODO(https://github.com/dart-lang/sdk/issues/51557): Decide if the mixins
// being applied in this test should be "mixin", "mixin class" or the test
// should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
import "inheritance_constraints_lib.dart" deferred as lib;
@@ -0,0 +1,45 @@
// Copyright (c) 2014, 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.
// Test using a class as a mixin.
// @dart=2.19
import "package:expect/expect.dart";
import "inheritance_constraints_legacy_lib.dart" deferred as lib;
class Foo {}
class Foo2 extends D {}
class A extends lib.Foo {}
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DEFERRED_CLASS
// [cfe] Classes can't extend deferred classes.
class B implements lib.Foo {}
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DEFERRED_CLASS
// [cfe] Classes and mixins can't implement deferred classes.
class C1 {}
class C = C1 with lib.Foo;
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_DEFERRED_CLASS
// [cfe] Classes can't mix in deferred mixins.
class D {
D();
factory D.factory() = lib.Foo2;
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_INVALID_RETURN_TYPE
// [cfe] The constructor function type 'Foo2 Function()' isn't a subtype of 'D Function()'.
}
void main() {
new A();
new B();
new C();
new D.factory();
}
@@ -0,0 +1,10 @@
// Copyright (c) 2014, 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.
// Test using classes as mixins.
// @dart=2.19
class Foo {}
class Foo2 {}
@@ -2,11 +2,6 @@
// 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.
// TODO(https://github.com/dart-lang/sdk/issues/51557): Decide if the mixins
// being applied in this test should be "mixin", "mixin class" or the test
// should be left at 2.19.
// @dart=2.19
mixin class Foo {}
class Foo {}
class Foo2 {}
mixin class Foo2 {}
@@ -1,43 +0,0 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2014, 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.
import "package:expect/expect.dart";
import "inheritance_constraints_lib.dart" deferred as lib;
mixin class Foo {}
class Foo2 extends D {}
class A extends
Foo {}
class B
implements
Foo {}
class C1 {}
class C = C1
with
Foo;
class D {
D();
factory D.factory() =
Foo2;
}
void main() {
new A();
new B();
new C();
new D.factory();
}
@@ -2,11 +2,6 @@
// 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.
// TODO(https://github.com/dart-lang/sdk/issues/51557): Decide if the mixins
// being applied in this test should be "mixin", "mixin class" or the test
// should be left at 2.19.
// @dart=2.19
// Test errors required by new enhanced enum syntax.
// Classes which implement `Enum`, but are not `enum` declarations,
@@ -40,6 +35,8 @@ abstract class AbstractImplementsWithValues implements Enum {
}
abstract class AbstractExtendsWithValues extends Enum {
// ^
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
int get values => 42;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_ENUM_VALUES
@@ -54,6 +51,8 @@ abstract class AbstractImplementsWithIndex implements Enum {
}
abstract class AbstractExtendsWithIndex extends Enum {
// ^
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
int get index => 42;
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
@@ -163,6 +162,7 @@ abstract class MixesInEnum with MyEnum {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// [cfe] The class 'MyEnum' can't be used as a mixin because it extends a class other than 'Object'.
// [cfe] The class 'MyEnum' can't be used as a mixin because it isn't a mixin class nor a mixin.
}
mixin MixinImplementsEnum implements MyEnum {
@@ -194,6 +194,7 @@ enum EnumMixesInEnum with MyEnum {
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// [cfe] The class 'MyEnum' can't be used as a mixin because it extends a class other than 'Object'.
// [cfe] The class 'MyEnum' can't be used as a mixin because it isn't a mixin class nor a mixin.
e1;
}
@@ -0,0 +1,46 @@
// Copyright (c) 2022, 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.
// Tests using a class as mixin.
// @dart=2.19
// Test errors required by new enhanced enum syntax, when used as a mixin.
// Not usable a mixin, even in language version that allows mixing in a class.
class MixesInEnum with Enum {
// ^
// [cfe] Non-abstract class 'MixesInEnum' has 'Enum' as a superinterface.
// [cfe] The non-abstract class 'MixesInEnum' is missing implementations for these members:
// ^^^^
// [analyzer] COMPILE_TIME_ERROR.CONCRETE_CLASS_HAS_ENUM_SUPERINTERFACE
}
// Currently no error, it's a simple class with no constructors that extends
// `Object`. (No reason to allow, will not be allowed in Dart 3.0.)
abstract class AbstractMixesInEnum with Enum {}
abstract class MixesInMyEnum with MyEnum {
// ^
// [cfe] 'MyEnum' is an enum and can't be extended or implemented.
// [cfe] Can't use 'MyEnum' as a mixin because it has constructors.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// [cfe] The class 'MyEnum' can't be used as a mixin because it extends a class other than 'Object'.
}
enum EnumMixesInEnum with MyEnum {
// ^
// [cfe] 'MyEnum' is an enum and can't be extended or implemented.
// [cfe] Can't use 'MyEnum' as a mixin because it has constructors.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// [cfe] The class 'MyEnum' can't be used as a mixin because it extends a class other than 'Object'.
e1;
}
void main() {}
enum MyEnum {
e1;
}
@@ -2,9 +2,7 @@
// 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.
// TODO(https://github.com/dart-lang/sdk/issues/51557): Decide if the mixins
// being applied in this test should be "mixin", "mixin class" or the test
// should be left at 2.19.
// Tests pre-3.0 behavior.
// @dart=2.19
// Object has a non-trivial constructor and hence cannot be used as mixin.
@@ -2,13 +2,27 @@
// 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.
// Formatting can break multitests, so don't format them.
// dart format off
class C1<T> extends Object with Malformed {}
// ^
// [cfe] The type 'Malformed' can't be mixed in.
// ^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// [cfe] Type 'Malformed' not found.
class C<T> extends Object
with Malformed // //# 01: compile-time error
with T // //# 02: compile-time error
with T<int> // //# 03: compile-time error
{}
class C2<T> extends Object with T {}
// ^
// [cfe] The type 'T' can't be mixed in.
// ^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// [cfe] The type variable 'T' can't be used as supertype.
main() => new C<C>();
class C3<T> extends Object with T<int> {}
// ^
// [cfe] The type 'T<int>' can't be mixed in.
// ^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
// [cfe] Can't use type arguments with type variable 'T'.
void main() {}
@@ -1,29 +0,0 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2018, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import 'package:expect/expect.dart';
class A {
}
class C extends Object with A {
test() {
print("Hello from test");
}
}
main() {
C c = new C();
c.test();
dynamic cc = c;
Expect.throwsNoSuchMethodError(() => cc.doesntExist());
}
@@ -1,33 +0,0 @@
// Copyright (c) 2018, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import 'package:expect/expect.dart';
class A {
noSuchMethod() {}
//^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
// [cfe] The method 'A.noSuchMethod' has fewer positional arguments than those of overridden method 'Object.noSuchMethod'.
}
class C extends Object with A {
// ^
// [cfe] Applying the mixin 'A' to 'Object' introduces an erroneous override of 'noSuchMethod'.
// ^
// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
test() {
print("Hello from test");
}
}
main() {
C c = new C();
c.test();
dynamic cc = c;
Expect.throwsNoSuchMethodError(() => cc.doesntExist());
}
+2 -6
View File
@@ -2,17 +2,13 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class S {}
class M1 {}
mixin M1 {}
class M2 {}
mixin M2 {}
class C = S with M1;
class D = S with M1, M2;
+2 -6
View File
@@ -2,16 +2,12 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class M1 = Object with M0;
mixin class M1 = Object with M0;
class M2 = Object with M1;
class M0 {
mixin M0 {
foo() => 42;
}
+4 -8
View File
@@ -1,11 +1,7 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// Copyright (c) 2023, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class A {
@@ -14,14 +10,14 @@ class A {
class B extends A with M1, M2, M3 {}
class M1 {}
mixin M1 {}
class M2 {
mixin M2 {
plain(x) => 'P $x';
bar(x, [y]) => '$y,$x';
}
class M3 {}
mixin M3 {}
makeB() {
return [new A(), new B()].last as B;
@@ -1,166 +0,0 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2018, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Signature conformance test.
abstract class CII {
int id(int x);
}
class CSI {
String id(int x) => "$x";
}
class CIS {
int id(String x) => 0;
}
class CTT<T> {
T id(T x) => x;
}
// Wrong return type.
// Wrong argument type.
// Similar as the above but using an instantiated class instead.
abstract class C5 = CII with CTT<int>;
abstract class C6 extends CII with CTT<int> {}
// Named parameters
abstract class NIIx {
int? id({int? x}) => x;
}
class NIIxy {
int? id({int? x, int? y}) => y;
}
class NIIy {
int? id({int? y}) => y;
}
class NII {
int? id(int? x) => x;
}
// It's OK to introduce more named parameters.
abstract class N1 = NIIx with NIIxy;
abstract class N2 extends NIIx with NIIxy {}
// It's NOT OK to rename named parameters.
// It's NOT OK to drop named parameters.
class NBABxy<A, B> {
B? id ({A? x, B? y}) => y;
}
class NTTy<T> {
T? id({T? y}) => y;
}
class NTTx<T> {
T? id(T? x) => x;
}
// Same as above but with generic classes.
abstract class N7 = NIIx with NBABxy<int, int>;
abstract class N8 extends NIIx with NBABxy<int, int> {}
// Optional positional parameters
abstract class OII {
int? id([int? x]) => x;
}
class OIII {
int? id([int? x, int? y]) => y;
}
class OIIy {
int? id([int? y]) => y;
}
class PII {
int? id(int? x) => x;
}
// It's OK to introduce more optional parameters.
abstract class O1 = OII with OIII;
abstract class O2 extends OII with OIII {}
// It's OK to rename optional parameters.
abstract class O3 = OII with OIIy;
abstract class O4 extends OII with OIIy {}
// It's NOT OK to drop optional parameters.
class OBAB<A, B> {
B? id ([A? x, B? y]) => y;
}
class OTTy<T> {
T? id([T? y]) => y;
}
class PTT<T> {
T? id(T? x) => x;
}
// Same as above but with generic classes.
abstract class O7 = OII with OBAB<int, int>;
abstract class O8 extends OII with OBAB<int, int> {}
abstract class O11 = OII with OTTy<int>;
abstract class O12 extends OII with OTTy<int> {}
// More tests with generic classes.
abstract class GTTnum {
T id<T extends num>(x);
}
class MTTnum {
T id<T extends num>(x) => x;
}
class MTTint {
T id<T extends int>(x) => x;
}
class MTT {
T id<T>(x) => x;
}
class MTTnumR {
T id<T extends num, R>(x) => x;
}
class G1 = GTTnum with MTTnum;
void main() {}
+20 -24
View File
@@ -2,24 +2,20 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Signature conformance test.
abstract class CII {
abstract mixin class CII {
int id(int x);
}
class CSI {
mixin CSI {
String id(int x) => "$x";
}
class CIS {
mixin CIS {
int id(String x) => 0;
}
class CTT<T> {
mixin CTT<T> {
T id(T x) => x;
}
@@ -67,15 +63,15 @@ abstract class NIIx {
int? id({int? x}) => x;
}
class NIIxy {
mixin NIIxy {
int? id({int? x, int? y}) => y;
}
class NIIy {
mixin NIIy {
int? id({int? y}) => y;
}
class NII {
mixin NII {
int? id(int? x) => x;
}
@@ -107,15 +103,15 @@ abstract class N6 extends NIIx with NII {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
class NBABxy<A, B> {
mixin NBABxy<A, B> {
B? id ({A? x, B? y}) => y;
}
class NTTy<T> {
mixin NTTy<T> {
T? id({T? y}) => y;
}
class NTTx<T> {
mixin NTTx<T> {
T? id(T? x) => x;
}
@@ -158,15 +154,15 @@ abstract class OII {
int? id([int? x]) => x;
}
class OIII {
mixin OIII {
int? id([int? x, int? y]) => y;
}
class OIIy {
mixin OIIy {
int? id([int? y]) => y;
}
class PII {
mixin PII {
int? id(int? x) => x;
}
@@ -188,15 +184,15 @@ abstract class O6 extends OII with PII {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
class OBAB<A, B> {
mixin OBAB<A, B> {
B? id ([A? x, B? y]) => y;
}
class OTTy<T> {
mixin OTTy<T> {
T? id([T? y]) => y;
}
class PTT<T> {
mixin PTT<T> {
T? id(T? x) => x;
}
@@ -231,19 +227,19 @@ abstract class GTTnum {
T id<T extends num>(x);
}
class MTTnum {
mixin MTTnum {
T id<T extends num>(x) => x;
}
class MTTint {
mixin MTTint {
T id<T extends int>(x) => x;
}
class MTT {
mixin MTT {
T id<T>(x) => x;
}
class MTTnumR {
mixin MTTnumR {
T id<T extends num, R>(x) => x;
}
class G1 = GTTnum with MTTnum;
+2 -6
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class S {
@@ -13,11 +9,11 @@ class S {
baz() => "S-baz";
}
class M1 {
mixin M1 {
bar() => "M1-bar";
}
class M2 {
mixin M2 {
bar() => "M2-bar";
baz() => "M2-baz";
fez() => "M2-fez";
+3 -7
View File
@@ -2,23 +2,19 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class M<T> {
mixin M<T> {
t() {
return T;
}
}
class A<U> = Object with M<U>;
mixin class A<U> = Object with M<U>;
class B<V> = Object with A<V>;
class C<U> = Object with M<List<U>>;
mixin class C<U> = Object with M<List<U>>;
class D<V> = Object with C<Set<V>>;
+6 -10
View File
@@ -2,29 +2,25 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class M<T> {
mixin M<T> {
t() {
return T;
}
}
class A<U> = Object with M<List<U>>;
mixin class A<U> = Object with M<List<U>>;
class B0 = Object with A<Set<bool>>;
class B1 = Object with A<Set<int>>;
mixin class B1 = Object with A<Set<int>>;
class C0 extends B0 {}
class C1 extends B1 {}
class A2<K, V> = Object with M<Map<K, V>>;
mixin class A2<K, V> = Object with M<Map<K, V>>;
class B2<V> = Object with A2<Set<V>, List<V>>;
@@ -34,13 +30,13 @@ class C2<T> extends B2<T> {}
class C3<T> extends B3<T, int> {}
class N {
mixin N {
q() {
return 42;
}
}
class O<U> = Object with N;
mixin class O<U> = Object with N;
class P<K, V> = Object with O<V>;
+2 -6
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class I<T> {}
@@ -14,13 +10,13 @@ class J<T> {}
class S<T> {}
class M<T> {
mixin M<T> {
t() {
return T;
}
}
class A<U, V> = Object with M<Map<U, V>> implements I<V>;
mixin class A<U, V> = Object with M<Map<U, V>> implements I<V>;
class C<T, K> = S<T> with A<T, List<K>> implements J<K>;
+3 -7
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class I<T> {}
@@ -16,15 +12,15 @@ class K<T> {}
class S<T> {}
class M<T> {
mixin M<T> {
m() {
return T;
}
}
class A<U, V> = Object with M<Map<U, V>> implements I<V>;
mixin class A<U, V> = Object with M<Map<U, V>> implements I<V>;
class B<T> = Object with A<T, Set<T>> implements J<T>;
mixin class B<T> = Object with A<T, Set<T>> implements J<T>;
class C<T> = S<List<T>> with B<List<T>> implements K<T>;
+3 -7
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class I<T> {}
@@ -16,15 +12,15 @@ class K<T> {}
class S<T> {}
class M<T> {
mixin M<T> {
m() {
return T;
}
}
class A<U, V> = Object with M<Map<U, V>> implements I<V>;
mixin class A<U, V> = Object with M<Map<U, V>> implements I<V>;
class B<T> = Object with A<T, Set<T>> implements J<T>;
mixin class B<T> = Object with A<T, Set<T>> implements J<T>;
class C<T> = S<List<T>> with B implements K<T>; // B is raw.
+3 -7
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class I<T> {}
@@ -16,15 +12,15 @@ class K<T> {}
class S<T> {}
class M<T> {
mixin M<T> {
m() {
return T;
}
}
class A<U, V> = Object with M implements I<V>; // M is raw.
mixin class A<U, V> = Object with M implements I<V>; // M is raw.
class B<T> = Object with A implements J<T>; // A is raw.
mixin class B<T> = Object with A implements J<T>; // A is raw.
class C<T> = S<List<T>> with B implements K<T>; // B is raw.
+4 -7
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class I<T> {}
@@ -16,15 +12,16 @@ class K<T> {}
class S<U extends Set<V>, V> {}
class M<U, V, T extends Map<U, V>> {
mixin M<U, V, T extends Map<U, V>> {
m() {
return T;
}
}
class A<U, V extends Set<U>> = Object with M<U, V, Map<U, V>> implements I<V>;
mixin class A<U, V extends Set<U>> =
Object with M<U, V, Map<U, V>> implements I<V>;
class B<T extends List<num>> = Object with A<T, Set<T>> implements J<T>;
mixin class B<T extends List<num>> = Object with A<T, Set<T>> implements J<T>;
class C<T extends num> = S<Set<T>, T> with B<List<T>> implements K<T>;
+3 -6
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class I<T> {}
@@ -14,13 +10,14 @@ class J<T> {}
class S<U extends Set<V>, V> {}
class M<U, V, T extends Map<U, V>> {
mixin M<U, V, T extends Map<U, V>> {
t() {
return T;
}
}
class A<U, V extends List> = Object with M<U, V, Map<U, V>> implements I<V>;
mixin class A<U, V extends List> =
Object with M<U, V, Map<U, V>> implements I<V>;
class C<T, K> = S<Set<T>, T> with A<T, List<K>> implements J<K>;
+2 -6
View File
@@ -2,17 +2,13 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class M1 {
mixin M1 {
foo() => 42;
}
class M2 = Object with M1;
mixin class M2 = Object with M1;
class S {}
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import 'package:expect/expect.dart' show Expect;
@pragma("vm:entry-point") // Prevent obfuscation
@@ -27,27 +23,27 @@ class E {}
class F {}
@pragma("vm:entry-point") // Prevent obfuscation
class M1<Tm1> {
mixin M1<Tm1> {
Type m1() => M1<Tm1>;
}
@pragma("vm:entry-point") // Prevent obfuscation
class M2<Tm2> {
mixin M2<Tm2> {
Type m2() => M2<Tm2>;
}
@pragma("vm:entry-point") // Prevent obfuscation
class M3<Tm3> {
mixin M3<Tm3> {
Type m3() => M3<Tm3>;
}
@pragma("vm:entry-point") // Prevent obfuscation
class M4<Tm4> {
mixin M4<Tm4> {
Type m4() => M4<Tm4>;
}
@pragma("vm:entry-point") // Prevent obfuscation
class M5<Tm5> {
mixin M5<Tm5> {
Type m5() => M5<Tm5>;
}
@@ -2,15 +2,11 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
var calls = <String>[];
abstract class A {
mixin A {
bool _done = true;
var a = calls.add('A()') as dynamic;
}
+3 -7
View File
@@ -2,19 +2,15 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class S {}
class M1 {}
mixin M1 {}
class M2 {}
mixin M2 {}
class M3 {}
mixin M3 {}
class C = S with M1, M2, M3;
+2 -6
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class Tester<T> {
@@ -18,13 +14,13 @@ abstract class A = B with C;
class B {}
class C {}
mixin C {}
class X extends Y with Z {}
class Y {}
class Z {}
mixin Z {}
main() {
// Classes A and X are only used as generic arguments.
@@ -2,20 +2,16 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class C0 {
mixin class C0 {
int m1() => 5;
int m2() => m1();
}
class C1 = Object with C0;
class D {
mixin D {
int m1() => 7;
}
+2 -2
View File
@@ -4,8 +4,8 @@
library mixin_prefix_lib;
import "dart:convert";
import "dart:convert" as convert;
mixin MixinClass {
String bar() => json.encode({'a': 1});
String bar() => convert.jsonEncode({'a': 1});
}
-4
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Regression test for issue 11891.
import "package:expect/expect.dart";
+1 -5
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Tests that a program in csp mode doesn't access the prototype chain
// on platforms that don't support direct access to __proto__.
// This test is most useful with --csp and on a platform that doesn't support
@@ -20,7 +16,7 @@ class A {
bar() => 22;
}
class B {
mixin class B {
var y;
foo() => 42;
}
@@ -2,20 +2,17 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Tests #31290
import "package:expect/expect.dart";
class A<T> {
mixin A<T> {
bool foo(T x) => true;
}
class B extends Object with A<B>, C<B> {}
// Tests #31290
class C<T> {}
mixin C<T> {}
main() {
var b = new B();
+2 -6
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
void main() {
@@ -26,11 +22,11 @@ abstract class Delegate {
String invoke(String value);
}
abstract class DelegateMixin {
mixin DelegateMixin {
String invoke(String value) => value;
}
abstract class HasValueMixin implements Delegate {
mixin HasValueMixin implements Delegate {
String _value = '';
set value(String value) {
_value = invoke(value);
+1 -5
View File
@@ -2,13 +2,9 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class ComparableMixin<E> {
mixin ComparableMixin<E> {
e() {
return E;
}
@@ -2,15 +2,11 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Verifies that references to deduplicated mixins are properly updated
// in types which are only accessible through constants.
// Regression test for https://github.com/flutter/flutter/issues/55345.
class Diagnosticable {}
mixin Diagnosticable {}
class SomeClass with Diagnosticable {}
@@ -2,14 +2,10 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Verifies that references to deduplicated mixins are properly updated.
// Regression test for https://github.com/flutter/flutter/issues/55345.
class Diagnosticable {}
mixin Diagnosticable {}
class SomeClass with Diagnosticable {}
+1 -5
View File
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Test that mixins don't interfere with type variable substitution.
import '../dynamic_type_helper.dart';
@@ -14,7 +10,7 @@ class B<T> {
B(T x);
}
class M {}
mixin M {}
class A<T> extends B<T> with M {
A(T x) : super(x); // This line must be warning free.
+1 -5
View File
@@ -2,13 +2,9 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class B {
mixin class B {
// 'super' resolves to Object, and in some tests, multiple points in the
// inheritance chain.
toString() => 'B(' + super.toString() + ')';
@@ -1,33 +0,0 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2015, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class M<U extends V, V> {}
class N<U, V extends U> {}
class S<T> {}
class MNA<U, V extends U, W> extends S<List<U>>
with M<V, U>, N<List<W>, List<W>> {}
class MNA2<U, V extends U, W> = S<List<U>> with M<V, U>, N<List<W>, List<W>>;
main() {
new MNA<num, int, bool>();
new MNA2<num, int, bool>();
// Type parameter U of M must extend type parameter V, but
// type argument num is not a subtype of int.
// Type parameter U of M must extend type parameter V, but
// type argument num is not a subtype of int.
}
+2 -6
View File
@@ -2,13 +2,9 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
mixin M<U extends V, V> {}
class M<U extends V, V> {}
class N<U, V extends U> {}
mixin N<U, V extends U> {}
class S<T> {}
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class Base {
@@ -14,7 +10,7 @@ class Base {
Base.ctor2(int i, this.j) : this.i = i + 8;
}
abstract class M {
abstract mixin class M {
get i;
get j;
int k = 42;
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class Base {
@@ -13,7 +9,7 @@ class Base {
Base(int i, this.j) : this.i = i + 7;
}
abstract class M {
abstract mixin class M {
int get i;
int get j;
int k = 42;
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class S {
@@ -13,9 +9,9 @@ class S {
S.foo() : i = 1742;
}
class M1 {}
mixin class M1 {}
class M2 {}
mixin class M2 {}
class C extends S with M1, M2 {
C.foo() : super.foo();
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class Base {
@@ -19,7 +15,7 @@ class Base {
}
}
abstract class M {
abstract mixin class M {
int? get i;
int? get j;
int k = 42;
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class Base {
@@ -18,7 +14,7 @@ class Base {
);
}
abstract class M {
abstract mixin class M {
int? get i;
int? get j;
int k = 42;
@@ -2,10 +2,6 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class Base {
@@ -13,7 +9,7 @@ class Base {
Base.ctor(int i, this.j) : this.i = i + 7;
}
abstract class M {
abstract mixin class M {
int get i;
int get j;
int k = 42;
+4 -8
View File
@@ -2,15 +2,11 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class M {}
mixin M {}
class P0 {
mixin P0 {
foo() {
super.toString();
@@ -28,7 +24,7 @@ class P0 {
}
}
class P1 {
mixin class P1 {
bar() {
super.toString();
return 87;
@@ -48,7 +44,7 @@ class P1 {
}
}
class P2 {
mixin class P2 {
baz() {
super.toString();
return 99;
@@ -1,129 +0,0 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2013, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class S0 {}
class S1 extends Object {}
class S2 extends S0 {}
class M0 {}
class M1 extends Object {}
mixin M2 on M0 {}
class C00 = S0 with M0;
class C01 = S0 with M1;
class C03 = S0 with M0, M1;
class C04 = S0 with M0, M2;
class C10 = S1 with M0;
class C11 = S1 with M1;
class C13 = S1 with M0, M1;
class C14 = S1 with M0, M2;
class C20 = S2 with M0;
class C21 = S2 with M1;
class C23 = S2 with M0, M1;
class C24 = S2 with M0, M2;
class D00 extends S0 with M0 {}
class D01 extends S0 with M1 {}
class D03 extends S0 with M0, M1 {}
class D04 extends S0 with M0, M2 {}
class D10 extends S1 with M0 {}
class D11 extends S1 with M1 {}
class D13 extends S1 with M0, M1 {}
class D14 extends S1 with M0, M2 {}
class D20 extends S2 with M0 {}
class D21 extends S2 with M1 {}
class D23 extends S2 with M0, M1 {}
class D24 extends S2 with M0, M2 {}
main() {
new C00();
new C01();
new C03();
new C04();
new C10();
new C11();
new C13();
new C14();
new C20();
new C21();
new C23();
new C24();
new D00();
new D01();
new D03();
new D04();
new D10();
new D11();
new D13();
new D14();
new D20();
new D21();
new D23();
new D24();
}
+2 -6
View File
@@ -2,19 +2,15 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class S0 {}
class S1 extends Object {}
class S2 extends S0 {}
class M0 {}
mixin M0 {}
class M1 extends Object {}
mixin class M1 extends Object {}
mixin M2 on M0 {}
@@ -1,32 +0,0 @@
// Copyright (c) 2016, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class B {}
class C {}
class D {}
class E extends B with C implements D {}
class F extends E {}
// M is mixed onto E which implements B, C and D.
mixin M //
on B //# 01: ok
on C //# 02: ok
on D //# 03: ok
on E //# 04: ok
on F //# 05: compile-time error
{}
class A extends E with M {}
main() {
new A();
}
@@ -0,0 +1,42 @@
// Copyright (c) 2016, 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.
class B {}
mixin C {}
class D {}
class E extends B with C implements D {}
class F extends E {}
// M is mixed onto E which implements B, C and D.
mixin MB on B {}
mixin MC on C {}
mixin MD on D {}
mixin ME on E {}
mixin MF on F {}
class AB extends E with MB {}
class AC extends E with MC {}
class AD extends E with MD {}
class AE extends E with ME {}
class AF extends E with MF {}
// ^
// [cfe] 'E' doesn't implement 'F' so it can't be used with 'MF'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class AB2 = E with MB;
class AC2 = E with MC;
class AD2 = E with MD;
class AE2 = E with ME;
class AF2 = E with MF;
// ^
// [cfe] 'E' doesn't implement 'F' so it can't be used with 'MF'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
main() {}
@@ -1,32 +0,0 @@
// Copyright (c) 2016, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class B {}
class C {}
class D {}
class E extends B with C implements D {}
class F extends E {}
// M is mixed onto E which implements B, C and D.
mixin M //
on B //# 01: ok
on C //# 02: ok
on D //# 03: ok
on E //# 04: ok
on F //# 05: compile-time error
{}
class A = E with M;
main() {
new A();
}
+3 -7
View File
@@ -2,17 +2,13 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
// Test that [:this:] in a class A used as a mixin in class D knows it can be an
// Test that `this` in a class A used as a mixin in class D knows it can be an
// instance of D.
import "package:expect/expect.dart";
class A {
foo() => bar(); // Implicit use of [:this:]
mixin class A {
foo() => bar(); // Implicit use of `this`
bar() => 42;
}
@@ -2,15 +2,11 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
abstract class Mixin1<T> {}
mixin Mixin1<T> {}
abstract class Mixin2<T> {}
mixin Mixin2<T> {}
class A {}
@@ -2,15 +2,11 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
abstract class Mixin1<T> {}
mixin Mixin1<T> {}
abstract class Mixin2<T> {}
mixin Mixin2<T> {}
class A {
A(foo);
@@ -2,15 +2,11 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
abstract class Mixin1<T> {}
mixin Mixin1<T> {}
abstract class Mixin2<T> {}
mixin Mixin2<T> {}
class A {
A(foo);
@@ -2,15 +2,11 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class R<E, F> {}
class M<J> implements R<bool, J> {}
mixin M<J> implements R<bool, J> {}
class B1 {}
@@ -2,19 +2,15 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class MixinA<T> {
mixin MixinA<T> {
T? intField;
}
class MixinB<S> {
mixin MixinB<S> {
S? stringField;
}
class MixinC<U, V> {
mixin MixinC<U, V> {
U? listField;
V? mapField;
}
@@ -2,13 +2,9 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class A<T> {}
class B<S> {
mixin B<S> {
int? foo(S s) => null;
}
@@ -2,21 +2,18 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
import "package:expect/static_type_helper.dart";
abstract class A<T> {
// This is ok because type inference will ensure that in C, A and M are
// instantiated with the same T.
T f(T x) => x; //# 01: ok
T f(T x) => x;
}
class B {}
abstract class M1 implements A<B> {}
mixin M1 implements A<B> {}
mixin M2<T> on A<T> {
T f(T x) => x;
@@ -30,12 +27,16 @@ class C extends Object with M1, M2 {}
main() {
C c = new C();
// M is instantiated with B, so C.g has type (B) -> B.
B Function(B) x = c.g; //# 02: ok
Null Function(Null) x = c.g; //# 03: compile-time error
Object Function(Object) x = c.g; //# 04: compile-time error
// M is instantiated with B.
A<B> asA = c; // Allowed.
// So C.g has type (B) -> B.
// Static type.
Expect.equals(typeOf<B Function(B)>(), c.g.staticType);
// Runtime type. Is covariant-by-generic, so actual argument type is Object?.
Expect.equals(typeOf<B Function(Object?)>(), c.g.runtimeType);
// And verify that the runtime system has the right type for the type
// parameter
Expect.equals(c.h(), B); //# 05: ok
Expect.equals(B, c.h());
}
@@ -2,11 +2,8 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
import "package:expect/static_type_helper.dart";
abstract class A<T> {
// This is ok because type inference will ensure that in C, A and M are
@@ -22,7 +19,7 @@ mixin M1<T> on A<T> {
Type h() => T;
}
class M2<T> {
mixin class M2<T> {
T g(T x) => x;
Type h() => T;
}
@@ -45,33 +42,25 @@ main() {
E e = new E();
F f = new F();
// M1 is instantiated with B, so C.g has type (B) -> B.
B Function(B) x = c.g; //# 02: ok
B Function(B) x = d.g; //# 03: ok
Null Function(Null) x = c.g; //# 04: compile-time error
Null Function(Null) x = d.g; //# 05: compile-time error
Object Function(Object) x = c.g; //# 06: compile-time error
Object Function(Object) x = d.g; //# 07: compile-time error
// M1 is instantiated with B, so C.g has static type (B) -> B.
Expect.equals(typeOf<B Function(B)>(), c.g.staticType);
// Is covariant-by-generics, so runtime parameter type is Object?.
Expect.equals(typeOf<B Function(Object?)>(), c.g.runtimeType);
// And verify that the runtime system has the right type for the type
// parameter
Expect.equals(c.h(), B); //# 08: ok
Expect.equals(c.h(), B); //# 09: ok
Expect.equals(B, c.h());
// M2 is instantiated with dynamic, so E.g has type (dynamic) -> dynamic.
dynamic Function(dynamic) x = e.g; //# 10: ok
B Function(B) x = e.g; //# 11: compile-time error
Expect.equals(typeOf<B Function(B)>(), d.g.staticType);
Expect.equals(typeOf<B Function(Object?)>(), d.g.runtimeType);
Expect.equals(B, d.h());
// And verify that the runtime system has the right type for the type
// parameter
Expect.equals(e.h(), dynamic); //# 12: ok
// M2 is instantiated with dynamic, E.g has static type (dynamic) -> dynamic.
Expect.equals(typeOf<dynamic Function(dynamic)>(), e.g.staticType);
Expect.equals(typeOf<dynamic Function(Object?)>(), e.g.runtimeType);
Expect.equals(dynamic, e.h());
// M2 is instantiated with B, so F.g has type (B) -> B.
B Function(B) x = f.g; //# 13: ok
Null Function(Null) x = f.g; //# 14: compile-time error
Object Function(Object) x = f.g; //# 15: compile-time error
// And verify that the runtime system has the right type for the type
// parameter
Expect.equals(f.h(), B); //# 16: ok
Expect.equals(typeOf<B Function(B)>(), f.g.staticType);
Expect.equals(typeOf<B Function(Object?)>(), f.g.runtimeType);
Expect.equals(B, f.h());
}
@@ -1,30 +0,0 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2013, 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class S<T> {}
class M<U> {}
class A<X> extends S<int> with M<double> {}
class F<X> = S<X> with M<X>;
main() {
var a;
a = new A();
a = new A<int>();
a = new F<int>();
}
@@ -2,13 +2,9 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
class S<T> {}
class M<U> {}
mixin M<U> {}
class A<X> extends S<int> with M<double> {}
class B<U, V> extends S with M<U, V> { }
@@ -2,13 +2,9 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class M<T> {
mixin M<T> {
bool matches(o) {
bool isChecked = checkUsingIs(o);
if (checkedMode) {
@@ -2,17 +2,14 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
import "package:expect/variations.dart";
class M<T> {
mixin M<T> {
bool matches(o) {
bool isChecked = checkUsingIs(o);
if (checkedMode) {
Expect.equals(isChecked, checkUsingCheckedMode(o));
bool isChecked = checkUsingIs(o); // `is` check.
if (checkedImplicitDowncasts) {
Expect.equals(isChecked, checkUsingDowncast(o)); // `as` check, implicit.
}
return isChecked;
}
@@ -21,24 +18,14 @@ class M<T> {
return o is T;
}
bool checkUsingCheckedMode(o) {
bool checkUsingDowncast(o) {
try {
T x = o;
T x = o as dynamic;
} on Error {
return false;
}
return true;
}
static final bool checkedMode = computeCheckedMode();
static bool computeCheckedMode() {
try {
int x = "foo" as dynamic;
} on Error {
return true;
}
return false;
}
}
class S {}
@@ -2,19 +2,15 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
class S {}
class M1<X> {
mixin M1<X> {
m1() => X;
}
class M2<Y> {
mixin M2<Y> {
m2() => Y;
}
@@ -2,17 +2,14 @@
// 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.
// TODO(51557): Decide if the mixins being applied in this test should be
// "mixin", "mixin class" or the test should be left at 2.19.
// @dart=2.19
import "package:expect/expect.dart";
import "package:expect/variations.dart";
class S<T> {
bool matches(o) {
bool isChecked = checkUsingIs(o);
if (checkedMode) {
Expect.equals(isChecked, checkUsingCheckedMode(o));
bool isChecked = checkUsingIs(o); // `is` check.
if (checkedImplicitDowncasts) {
Expect.equals(isChecked, checkUsingDowncast(o)); // `as` check, implicit.
}
return isChecked;
}
@@ -21,27 +18,17 @@ class S<T> {
return o is T;
}
bool checkUsingCheckedMode(o) {
bool checkUsingDowncast(o) {
try {
T x = o;
T x = o as dynamic;
} on Error {
return false;
}
return true;
}
static final bool checkedMode = computeCheckedMode();
static bool computeCheckedMode() {
try {
int x = "foo" as dynamic;
} on Error {
return true;
}
return false;
}
}
class M {}
mixin M {}
class C0<T> extends S with M {}

Some files were not shown because too many files have changed in this diff Show More