Skip to content

Added macro for passing all arguments of a method as implicit parameter #14

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

Merged
merged 4 commits into from
May 24, 2016

Conversation

benhag
Copy link

@benhag benhag commented Apr 23, 2016

No description provided.

@fizzy33
Copy link

fizzy33 commented Apr 23, 2016

Looks cool... Might want to add another assert in the unit test

assert(args.value(1).size == 2

@lihaoyi
Copy link
Member

lihaoyi commented Apr 23, 2016

Fascinating.

Any chance you could get it working scala-2.10? You probably just need to swap out paramLists for paramss or something similar.

I also would like a test case that includes a constructor as the nearest-enclosing-method, just to make sure it behaves in that scenario

@lihaoyi
Copy link
Member

lihaoyi commented Apr 23, 2016

Only slightly related, but it would be cool to have an implicit for "everything in scope" rather than just the nearest-enclosing-method's parameters. It would be huge, and we would have to synthesize fake objects to get around the silly package foo is not a value problems, but it would be useful for similar reasons a the current PR

@benhag
Copy link
Author

benhag commented Apr 23, 2016

Already trying to get it working in scala-2.10.

@benhag
Copy link
Author

benhag commented Apr 23, 2016

I've fixed the 2.10 compatibility, but it's currently not working with a constructor as nearest enclosing method. Still working on this...

…h Scala 2.11

- Workaround for evaluation of arguments passed to the primary constructor with Scala 2.10
- Added test for implicit parameter lists
- Added test for empty parameter lists
@benhag
Copy link
Author

benhag commented Apr 24, 2016

I'm probably just missing something, but I haven't found a way to access the constructor parameter with Scala 2.10.
Here is what I've done:

  • With 2.11 it is working as expected, for a constructor as well as for a method
  • With 2.10 it is working for method or alternate constructors. Within the primary constructor Args.value will be an empty list. So at least one wont get any compiler errors

@benhag
Copy link
Author

benhag commented Apr 25, 2016

I'm not sure that it's a good idea to pass an empty list if Args is used within a primary constructor in 2.10. It might be better to abort the build with a clear compiler error - as long as nobody has an idea how to access the constructor arguments.

@benhag
Copy link
Author

benhag commented Apr 25, 2016

Ok, found a way to access the constructor parameters in 2.10.

@lihaoyi
Copy link
Member

lihaoyi commented May 24, 2016

Looks good, thanks!

@lihaoyi lihaoyi merged commit 017d3fc into com-lihaoyi:master May 24, 2016
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

Successfully merging this pull request may close these issues.

3 participants