dart-sdk/tests/language/least_upper_bound/runtime_4_test.dart
Robert Nystrom 1b8f589d3c Migrate language_2/least_upper_bound to NNBD.
Change-Id: Id1cffba25214323478af50a8ae539236377d53c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149047
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2020-05-30 00:55:26 +00:00

99 lines
1.1 KiB
Dart

// 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.
// Test least upper bound through type checking of conditionals.
class A {
var a;
}
class B {
var b;
}
class C extends B {
var c;
}
class D extends B {
var d;
}
class E<T> {
T e;
E(this.e);
}
class F<T> extends E<T> {
T f;
F(T f)
: this.f = f,
super(f);
}
void main() {
testAB(new A(), new B());
testBC(new C(), new C());
testCD(new C(), new D());
testEE(new F<C>(new C()), new F<C>(new C()));
testEF(new F<C>(new C()), new F<C>(new C()));
}
void testAB(A a, B b) {
var c = new C();
(false ? c : b).b = 0;
}
void testBC(B b, C c) {
var a = null;
}
void testCD(C c, D d) {
}
void testEE(E<B> e, E<C> f) {
// The least upper bound of E<B> and E<C> is E<B>.
}
void testEF(E<B> e, F<C> f) {
// The least upper bound of E<B> and F<C> is E<B>.
var r5;
}