Skip to content

Implement implicit call method tear-offs with extension typed receivers #54339

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 Dec 13, 2023 · 3 comments
Closed
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 Dec 13, 2023

This implementation issue is associated with the proposal in dart-lang/language#3467, that is, the proposal to support implicit call method tear-offs for receivers whose static type is an extension type.

Consider the following example:

extension type Ext(Function it) {
  String call() => 'call from Ext: ${it()}';
}

class C {
  String call() => 'call from C';
}

class D {
  Function get fgetter => Ext(C()); // (1)
}

void main() {
  var d = D();
  print(d.fgetter());
}

At (1) in this example, we evaluate the expression Ext(C()) with a context type of Function. Following the treatment of a receiver of an interface type that has a method named call, this expression should be implicitly transformed into Ext(C()).call, and the resulting program would then be type correct.

(Of course, C() will be subject to the same transformation because that's the case that we already support, yielding Ext(C().call).call.)

This issue serves as a request to implement this feature. It may be implemented in the analyzer already, but the CFE reports an error when Ext(...) is encountered with context type Function. I'll create subtask issues for both, and then the analyzer subtask may be trivial.

Subtasks:

@eernstg
Copy link
Member Author

eernstg commented Dec 15, 2023

Oh, @johnniwinther, perhaps it was #54341 that should have been closed?

@johnniwinther
Copy link
Member

Yes

@johnniwinther johnniwinther reopened this Dec 15, 2023
@eernstg
Copy link
Member Author

eernstg commented Jan 29, 2024

Done.

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

2 participants