// 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. // @dart=2.9 /*@testedFeatures=checks*/ class A { void Function(S x) foo() { print('foo: T = $T'); return (S a) {}; } } class B { void Function(T x) foo() { print('foo: T = $T'); return (T a) {}; } } A a = new A(); B b = new B(); main() { try { a.foo /*@ checkReturn=(S*) ->* void */ (); throw 'Expected TypeError'; } on TypeError catch (e) { print(e); } try { b.foo /*@ checkReturn=(num*) ->* void */ (); throw 'Expected TypeError'; } on TypeError catch (e) { print(e); } }