Skip to content

[cfe] Implement generic method instantiation on call of function object #47147

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

Closed
eernstg opened this issue Sep 8, 2021 · 0 comments
Closed
Assignees
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@eernstg
Copy link
Member

eernstg commented Sep 8, 2021

Thanks to @sgrekhov for raising this issue. As part of the constructor-tearoffs feature, it is no longer a compile-time error to perform a generic method instantiation on the call method of an expression whose static type is a generic function type. For instance:

X id<X>(X x) => x;

main() {
  var idVar = id;
  int Function(int) f = idVar.call;
  var g = idVar.call<int>;
}

The analyzer accepts this program as it should, but the CFE (dart from commit 02b2e6c) rejects it with the following error message:

n007.dart:5:31: Error: A value of type 'X Function<X>(X)' can't be assigned to a variable of type 'int Function(int)'.
  int Function(int) f = idVar.call;
                              ^

This issue is concerned with the implementation of support for doing this.

@eernstg eernstg added the legacy-area-front-end Legacy: Use area-dart-model instead. label Sep 8, 2021
@johnniwinther johnniwinther self-assigned this Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

2 participants