Open CoderBuck opened 11 months ago
Looks like horizontal inference might need to be updated to take record types into account. @stereotype441, WDYT?
Here is a more concise example:
void f<X, Y>((X, Y) pair, void Function(X x, Y y) func) {}
void main() => f((1, 2), (x, y) => x + y); // Error because parameters have type `Object?`.
Agree that it's record-related. If I change Erik's example to:
void f<X, Y>(Pair<X, Y> pair, void Function(X x, Y y) func) {}
void main() => f(const Pair(1, 2),
(x, y) => x + y); // Error because parameters have type `Object?`.
class Pair<X, Y> {
final X x;
final Y y;
const Pair(this.x, this.y);
}
then it works. Records should be at least as easy to infer as the corresponding class.
Seems to be Analyzer only, Dart2JS (in DartPad) accepts the program.
code: