Skip to content

Implement support for generic function instantiation of existing function objects in constants #47150

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
6 tasks done
eernstg opened this issue Sep 8, 2021 · 3 comments
Closed
6 tasks done
Assignees
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool)

Comments

@eernstg
Copy link
Member

eernstg commented Sep 8, 2021

With dart-lang/language#1812, support for generic function instantiation of an existing function object was added to Dart. This issue is concerned with adding support for the same feature for constant expressions. For example:

class A {
  final int Function(int) x;
  const A(bool b): x = (b ? id : other)<int>; // OK, `(...)<T1..Tk>` is potentially constant.
}

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

void main() {
  const c1 = id<int>; // Already supported prior to the addition on this feature.
  const c2 = id; // Make `c2` a constant expression whose value is a function object.
  const c3 = c2<int>; // OK, perform generic function instantiation on `c2`.
  const c4 = A(true); // OK, `(b ? id : other)<int>` is constant after substitution `b` -> `true`.
}

Along with these explicit forms, the implicit forms (guided by the context type) should be supported as well.

This feature is part of the constructor-tearoffs feature bundle.

Subtasks:

@devoncarew
Copy link
Member

@eernstg - just confirming that this is related to constructor tearoffs?

@eernstg
Copy link
Member Author

eernstg commented Oct 6, 2021

Yes, the ability to create a generic function instantiation explicitly (e.g., myFunction<int>) was introduced as part of the constructor-tearoffs feature bundle, and this issue is concerned with a part of that feature.

@devoncarew
Copy link
Member

Gotch, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool)
Projects
None yet
Development

No branches or pull requests

3 participants