// Copyright (c) 2020, 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. // The test checks that if one type isn't assignable to the other only because // of the nullability modifiers, the error message reflects that. import 'dart:async'; class A { const A(); } class B extends A {} class C { num? call() {} } void fooContext(A x) {} void barContext(List x) {} void bazContext(num Function() f) {} A foo(B? x, List l, Map m, List? l2, Map? m2) { fooContext(x); // Error. A a = x; // Error. [...l]; // Error. [...l2]; // Error. {...m}; // Error. {...m2}; // Error. for (A y in l) {} // Error. for (A y in l2) {} // Error. switch (x) /* Error. */ { case const A(): break; default: break; } FutureOr local() async { if (true) { return x; // Error. } else { return new Future.value(x); // Error. } } return x; // Error. } List bar(List x, List> l, Map, List> m) { barContext(x); // Error. List y = x; // Error. >[...l]; // Error. , List>{...m}; // Error. for (List y in l) {} // Error. return x; // Error. } void baz(C c) { bazContext(c); } A boz(Null x) { fooContext(x); // Error. fooContext(null); // Error. A a1 = x; // Error. A a2 = null; // Error. if (true) { return x; // Error. } else { return null; // Error. } FutureOr local() async { if (true) { return null; // Error. } else { return new Future.value(null); // Error. } } } main() {}