blob: e382152a188bc7578f79662a8d4cd6bad09887c8 [file] [log] [blame]
/*
* 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.
*/
/**
* @assertion We say that a type T0 is a subtype of a type T1 (written T0 <: T1)
* when:
* Interface Compositionality: T0 is an interface type
* C0<S0, ..., Sk> and T1 is C0<U0, ..., Uk> and each Si <: Ui
* @description Check that if type T0 is an interface type
* C0<S0, ..., Sk> and T1 is C0<U0, ..., Uk> and not all of Si <: Ui then T0 is
* not a subtype of T1
* @author sgrekhov@unipro.ru
*/
/**
* @description Check that if type T0 not a subtype of a type T1, then it cannot
* be used as an argument of type T1. Test mixin members
* @author sgrekhov@unipro.ru
*/
/*
* This test is generated from interface_compositionality_fail_A01.dart and
* arguments_binding_fail_x03.dart.
* Don't modify it. If you want to change this file, change one of the files
* above and then run generator.dart to regenerate the tests.
*/
import '../../utils/common.dart';
import '../../../../Utils/expect.dart';
abstract class U0 {}
abstract class U1 {}
abstract class U2 {}
abstract class S0 extends U0 {}
abstract class S1 extends U1 {}
// no subtype relation between S2 and U2
abstract class S2 {}
class C0<X, Y, Z> {}
C0<S0, S1, S2> t0Instance = new C0<S0, S1, S2>();
C0<U0, U1, U2> t1Instance = new C0<U0, U1, U2>();
class ArgumentsBindingSuper1_t03 {
void superTest(C0<U0, U1, U2> val) {}
void superTestPositioned(C0<U0, U1, U2> val, [C0<U0, U1, U2> val2]) {}
void superTestNamed(C0<U0, U1, U2> val, {C0<U0, U1, U2> val2}) {}
C0<U0, U1, U2> get superGetter => forgetType(t0Instance);
void set superSetter(C0<U0, U1, U2> val) {}
}
class ArgumentsBinding1_t03 extends Object with ArgumentsBindingSuper1_t03 {
test() {
Expect.throws(() {
superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
this.superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
super.superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
superGetter;
}, (e) => e is TypeError);
Expect.throws(() {
this.superGetter;
}, (e) => e is TypeError);
Expect.throws(() {
super.superGetter;
}, (e) => e is TypeError);
}
}
class ArgumentsBindingSuper2_t03<X> {
void superTest(X val) {}
void superTestPositioned(X val, [X val2]) {}
void superTestNamed(X val, {X val2}) {}
X get superGetter => forgetType(t0Instance);
void set superSetter(X val) {}
}
class ArgumentsBinding2_t03<X> extends Object with ArgumentsBindingSuper2_t03<X> {
test() {
Expect.throws(() {
superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
this.superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
super.superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
this.superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
super.superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
superGetter;
}, (e) => e is TypeError);
Expect.throws(() {
this.superGetter;
}, (e) => e is TypeError);
Expect.throws(() {
super.superGetter;
}, (e) => e is TypeError);
}
}
main() {
// test class members
Expect.throws(() {
new ArgumentsBinding1_t03().superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding1_t03().superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding1_t03().superTestPositioned(t1Instance, forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding1_t03().superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding1_t03().superTestNamed(t1Instance, val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding1_t03().superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding1_t03().superGetter;
}, (e) => e is TypeError);
new ArgumentsBinding1_t03().test();
// Test type parameters
//# <-- NotGenericFunctionType
// test generic class members
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().superGetter;
}, (e) => e is TypeError);
new ArgumentsBinding2_t03<C0<U0, U1, U2>>().test();
//# -->
}