Closed
Description
EDIT by @jmesserly: see comment here #29778 (comment) for description of the problem.
This bug has been recurring rather often and showed up in several other bugs, #30822 and #30207
original bug description by Leaf follows:
The following program:
void main() {
Null Function<R>(R Function(int)) f = <S>(g) {};
}
produces the following incorrect error when run against bleeding edge analyzer:
error • A value of type '<S₀>((int) → S) → Null' can't be assigned to a variable of type '<R>((int) → R) → Null' at /Users/leafp/tmp/test.dart:2:41 • invalid_assignment
The inferred type for the lambda is <S₀>((int) → S) → Null
, instead of the presumably correct <S₀>((int) → S₀) → Null
.
It looks like downwards inference is correctly choosing a new canonical type variable S₀
to use to match up R
and S
, but is then constructing the final inferred type using a mix of S
and
S₀
to produce an invalid type.