-
Notifications
You must be signed in to change notification settings - Fork 1.7k
synthetic function types are not substituted correctly #29778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
possibly related substitution problem: #30207 |
so, this happens any time we construct a (synthetic) function type, such as in TypeSystem. The resulting object cannot be substituted correctly because its free variable list ( This is going to be tricky to fix, but I'm working on it. Other interesting finds:
EDIT: also we need to fix TypeParameterElement.==/hashCode so they work correctly for synthetic type parameters. |
Here are two more repros from #30822 main() {
T Function() Function<T>() g =
<S>() {
S Function() f;
if (f != null) return f;
return () => f();
};
} and // Wants a function that takes a function and returns a same-typed function.
void foo(T Function() Function<T>(T Function() f) parameterName) {}
// Using a function literal. -> the return type needs to be inferred.
foo(<T>(T Function() f) {
if (true) return f;
return () => f();
}); |
another example from #30207 is tests/language_2/generic_methods_generic_function_result_test.dart |
this was recently fixed https://dart-review.googlesource.com/c/sdk/+/59160, #33159 |
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:
produces the following incorrect error when run against bleeding edge analyzer:
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 upR
andS
, but is then constructing the final inferred type using a mix ofS
andS₀
to produce an invalid type.The text was updated successfully, but these errors were encountered: