| 
 | 1 | +// Copyright (c) 2025, the Dart project authors.  Please see the AUTHORS file  | 
 | 2 | +// for details. All rights reserved. Use of this source code is governed by a  | 
 | 3 | +// BSD-style license that can be found in the LICENSE file.  | 
 | 4 | + | 
 | 5 | +typedef F<X> = X Function(X);  | 
 | 6 | + | 
 | 7 | +extension<X> on X {  | 
 | 8 | +  X m<Y extends F<X>>() => this;  | 
 | 9 | +}  | 
 | 10 | + | 
 | 11 | +void test1() {  | 
 | 12 | +  g() sync* {  | 
 | 13 | +    yield 1;  | 
 | 14 | +    yield null;  | 
 | 15 | +  }  | 
 | 16 | + | 
 | 17 | +  g.m<F<Iterable<int?> Function()>>();  | 
 | 18 | +  g.m<F<Iterable<int?> Function()>>;  | 
 | 19 | +  g.m<F<Iterable<int> Function()>>();  | 
 | 20 | +  //^  | 
 | 21 | +  // [cfe] Type argument 'Iterable<int> Function() Function(Iterable<int> Function())' doesn't conform to the bound 'X Function(X)' of the type variable 'Y' on 'm'.  | 
 | 22 | +  //  ^^^^^^^^^^^^^^^^^^^^^^^^^^^  | 
 | 23 | +  // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS  | 
 | 24 | +  g.m<F<Iterable<int> Function()>>;  | 
 | 25 | +  // ^  | 
 | 26 | +  // [cfe] Type argument 'Iterable<int> Function() Function(Iterable<int> Function())' doesn't conform to the bound 'Iterable<int?> Function() Function(Iterable<int?> Function())' of the type variable 'Y' on 'Iterable<int?> Function() Function<Y extends Iterable<int?> Function() Function(Iterable<int?> Function())>()'.  | 
 | 27 | +  //  ^^^^^^^^^^^^^^^^^^^^^^^^^^^  | 
 | 28 | +  // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS  | 
 | 29 | +}  | 
 | 30 | + | 
 | 31 | +void test2(Iterable<int?> h()) {  | 
 | 32 | +  h.m<F<Iterable<int?> Function()>>();  | 
 | 33 | +  h.m<F<Iterable<int?> Function()>>;  | 
 | 34 | +  h.m<F<Iterable<int> Function()>>();  | 
 | 35 | +  //^  | 
 | 36 | +  // [cfe] Type argument 'Iterable<int> Function() Function(Iterable<int> Function())' doesn't conform to the bound 'X Function(X)' of the type variable 'Y' on 'm'.  | 
 | 37 | +  //  ^^^^^^^^^^^^^^^^^^^^^^^^^^^  | 
 | 38 | +  // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS  | 
 | 39 | +  h.m<F<Iterable<int> Function()>>;  | 
 | 40 | +  // ^  | 
 | 41 | +  // [cfe] Type argument 'Iterable<int> Function() Function(Iterable<int> Function())' doesn't conform to the bound 'Iterable<int?> Function() Function(Iterable<int?> Function())' of the type variable 'Y' on 'Iterable<int?> Function() Function<Y extends Iterable<int?> Function() Function(Iterable<int?> Function())>()'.  | 
 | 42 | +  //  ^^^^^^^^^^^^^^^^^^^^^^^^^^^  | 
 | 43 | +  // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS  | 
 | 44 | +}  | 
0 commit comments