Open eernstg opened 4 months ago
As we discussed offline, the problem seems to arise from the inference having to separate sets of constraints: one for X
, the type variable of f
, and E
, the type variable of the list literal <E>[]
. Solving for E
happens first, yielding E = dynamic
in the absence of type information, and then List<dynamic>
informs the inference on X
from the constraint List<dynamic> <: List<X>
.
A possible solution for this situation is to allow joined constraint sets for the nested expressions.
Consider the following program:
Both the analyzer and the CFE reject this program, reporting that "
X
couldn't be inferred" respectively "'int Function(int)' can't be assigned to the parameter type 'dynamic Function(dynamic)'".The horizontal inference rules do not give rise to any separation of the actual arguments into phases, so I'd expect the declared parameter type
int
as well as the return typeint
of the second argument to suffice to conclude thatX
must beint
.