mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
2658f495f2
Change-Id: Ic30aef0302e1d2a2812eeb81b414a69e7591f625 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149622 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
42 lines
1.3 KiB
Dart
42 lines
1.3 KiB
Dart
// 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
// Test various invalid mixin applications where the supertype doesn't
|
|
// implement the super-interfaces.
|
|
|
|
abstract class UnaryNum {
|
|
num foo(num x) => x;
|
|
}
|
|
|
|
abstract class UnaryInt {
|
|
num foo(int x) => x;
|
|
}
|
|
|
|
mixin M1 on UnaryNum {}
|
|
|
|
class _ = Object with M1; //# 01: compile-time error
|
|
class _ = Null with M1; //# 02: compile-time error
|
|
class _ = UnaryInt with M1; //# 03: compile-time error
|
|
|
|
mixin M2 on UnaryNum, UnaryInt {}
|
|
|
|
class _ = UnaryInt with M2; //# 04: compile-time error
|
|
class _ = UnaryNum with M2; //# 05: compile-time error
|
|
|
|
// Note that it is not sufficient for the application to declare that it
|
|
// implements the super-interface.
|
|
abstract class _ = Object with M1 implements UnaryNum; //# 06: compile-time error
|
|
|
|
// Nor is it sufficient, in the case of an anonymous mixin application, for the
|
|
// containing class to declare that it implements the super-interface.
|
|
abstract class _ extends Object with M1 implements UnaryNum {} //# 07: compile-time error
|
|
|
|
main() {
|
|
// M1 and M2 are valid types.
|
|
Expect.notType<M1>(null);
|
|
Expect.notType<M2>(null);
|
|
}
|