Skip to content

Explicit extension operator invocations tested? #495

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 Oct 17, 2019 · 2 comments
Closed

Explicit extension operator invocations tested? #495

eernstg opened this issue Oct 17, 2019 · 2 comments
Assignees

Comments

@eernstg
Copy link
Member

eernstg commented Oct 17, 2019

Cf. dart-lang/sdk#38895, I took a look at the co19 tests on extension methods. I think they don't cover the case where an explicitly resolved extension method invocation calls an operator (example derived from this one):

extension X on bool {
  bool operator+(bool other) => this | other;
}

main() {
  print(X(false) + true);
}

I searched for strings like ) + and ) *, but did not find examples where this feature is used.

@sgrekhov sgrekhov self-assigned this Oct 17, 2019
@sgrekhov
Copy link
Contributor

Test uses operator "-" (unary minus). It defined here and used, for example, here. Is this desired test?

@eernstg
Copy link
Member Author

eernstg commented Oct 17, 2019

Not quite: The point is that an analysis which is a little bit too fast would say that X(false) + true is an error because X(false) cannot occur as an expression. But the addition is just an instance method invocation, so even though it is different syntactically it is similar to X(false).foo(true) where foo is an extension method declared in the extension X.

And I couldn't find any test cases where explicit resolution of an extension operator is used (like X(false) + true, as opposed to the implicit ones like false + true). The example using unary minus is also implicit: -list and -list.split(1); the explicitly resolved version would be -MyFancyList(list) and -MyFancyList(list.split(1)).

sgrekhov pushed a commit that referenced this issue Oct 30, 2019
sgrekhov pushed a commit that referenced this issue Oct 31, 2019
sgrekhov pushed a commit that referenced this issue Nov 5, 2019
sgrekhov pushed a commit that referenced this issue Nov 6, 2019
sgrekhov pushed a commit that referenced this issue Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants