blob: 7d10c013971f4e71ab58737ee5c7d7a2bbde9a13 [file] [log] [blame] [edit]
// Copyright (c) 2026, 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.
// SharedOptions=--enable-experiment=anonymous-methods
import '../../static_type_helper.dart';
void context<X>(X _) {}
void main() {
// Verify the context type via its effect on type inference.
context<List<num>>(''.{
return []..expectStaticType<Exactly<List<num>>>;
});
context<Future<Pattern>>(''.{
return Future.value('')..expectStaticType<Exactly<Future<Pattern>>>;
});
// Verify that the context type can give rise to coercions.
context<int>(''.{
return 1..expectStaticType<Exactly<int>>;
});
context<double>(''.{
return 1..expectStaticType<Exactly<double>>;
});
context<void Function(bool)>(''.{
return context..expectStaticType<Exactly<void Function(bool)>>;
});
}