// 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. import 'package:expect/expect.dart'; class Expect { static isTrue(bool cond, String message) { if (!cond) throw message; } } class A {} class B {} class C extends B {} class D extends B {} class E {} class F extends E {} void main() { checkType(true ? A() : B())(); checkType(true ? B() : C())(); checkType(true ? C() : D())(); checkType(true ? E() : E())>(); checkType(true ? E() : F())>(); } /// Tests that [A] (which should be inferred from the expression for [actual] /// is the same as [E]. void Function() checkType(A actual) { return () { Expect.isTrue([] is List && [] is List, "Argument expression should have inferred type '$E' but was '$A'."); }; }