blob: 8d636b80e011488bdd6ec9d3c4c6626af67a39ca [file] [log] [blame]
/*
* Copyright (c) 2019, 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:
* Right Object: if T1 is Object then:
* - if T0 is an unpromoted type variable with bound B then T0 <: T1 iff
* B <: Object
* - if T0 is a promoted type variable X & S then T0 <: T1 iff S <: Object
* - if T0 is FutureOr<S> for some S, then T0 <: T1 iff S <: Object.
* - if T0 is S* for any S, then T0 <: T1 iff S <: T1
* - if T0 is Null, dynamic, void, or S? for any S, then the subtyping does not
* hold (per above, the result of the subtyping query is false).
* - Otherwise T0 <: T1 is true.
* @description Check that if T0 is FutureOr<S> for some S but S is not subtype
* of Object then T0 is not 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 right_object_fail_A03.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';
// SharedOptions=--enable-experiment=non-nullable
import "dart:async";
class S {}
FutureOr<S?> t0Instance = new Future.value(new S());
Object t1Instance = new Object();
const t1Default = const Object();
class ArgumentsBindingSuper1_t03 {
void superTest(Object val) {}
void superTestPositioned(Object val, [Object val2]) {}
void superTestNamed(Object val, {Object val2}) {}
Object get superGetter => forgetType(t0Instance);
void set superSetter(Object 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<Object>().superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<Object>().superTest(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<Object>().superTestPositioned(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<Object>().superTestPositioned(forgetType(t1Instance), forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<Object>().superTestNamed(forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<Object>().superTestNamed(forgetType(t1Instance), val2: forgetType(t0Instance));
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<Object>().superSetter = forgetType(t0Instance);
}, (e) => e is TypeError);
Expect.throws(() {
new ArgumentsBinding2_t03<Object>().superGetter;
}, (e) => e is TypeError);
new ArgumentsBinding2_t03<Object>().test();
//# -->
}