-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
cfe-dysfunctionalitiesIssues for the CFE not behaving as intendedIssues for the CFE not behaving as intendedlegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Description
I would expect the following code to compile:
typedef BoundedFunction<R, Bound> = R Function<T extends Bound>(T value);
class BoundedClass<R, Bound> {
const BoundedClass(this.run);
final BoundedFunction<R, Bound> run;
}
void main() {
final BoundedFunction<int, String> boundedFunction = <Y extends String>(Y value) => 1;
final BoundedClass<int, String> boundedClass = BoundedClass(boundedFunction);
}However the compiler throws a error at the last line:
lib/fn.dart:13:63: Error: The argument type 'int Function<T extends String>(T)' can't be assigned to the parameter type 'int Function<T extends String>(T)' because 'T' is nullable and 'T' isn't.
final BoundedClass<int, String> boundedClass = BoundedClass(boundedFunction);
^
Not sure if its a bug, but at least the message is very confusing.
dart --version: Dart SDK version: 3.5.0 (stable) (Tue Jul 30 02:17:59 2024 -0700) on "macos_arm64"
FMorschel
Metadata
Metadata
Assignees
Labels
cfe-dysfunctionalitiesIssues for the CFE not behaving as intendedIssues for the CFE not behaving as intendedlegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.