2014-05-08 08:10:12 +00:00
|
|
|
// 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 that generic types in mixins are handled.
|
|
|
|
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
|
|
|
|
class M<T> {
|
2017-08-30 15:50:11 +00:00
|
|
|
T field1 = 0; //# 01: compile-time error
|
|
|
|
T field2 = 0 as dynamic;
|
2014-05-08 08:10:12 +00:00
|
|
|
}
|
2017-04-17 21:52:57 +00:00
|
|
|
|
2014-05-08 08:10:12 +00:00
|
|
|
class A<U> {}
|
2017-04-17 21:52:57 +00:00
|
|
|
|
2014-05-08 08:10:12 +00:00
|
|
|
class C1<V> = Object with M<V>;
|
|
|
|
class C2 = Object with M<int>;
|
|
|
|
class C3 = Object with M<String>;
|
|
|
|
|
|
|
|
main() {
|
2017-08-30 15:50:11 +00:00
|
|
|
// no error: 0 is an int
|
|
|
|
new C1<int>();
|
|
|
|
new C2();
|
|
|
|
|
|
|
|
// type error: 0 is not a string
|
2017-10-17 23:37:15 +00:00
|
|
|
Expect.throwsTypeError(() => new C1<String>());
|
|
|
|
Expect.throws(() => new C3());
|
2017-04-17 21:52:57 +00:00
|
|
|
}
|