Skip to content
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

issues with accessor methods #36

Open
oyvindberg opened this issue Jun 21, 2015 · 7 comments
Open

issues with accessor methods #36

oyvindberg opened this issue Jun 21, 2015 · 7 comments

Comments

@oyvindberg
Copy link

I've been doing some scalajs hacking lately, and had a look at autowire the other day.
I exported a trait with an accessor method (no parameters), and that made my project stop compiling.

It really took me a while to figure out why, so i made a PR with a failing (that is, doesnt compile) test, so we can work it out. See #35

@bkkoo
Copy link

bkkoo commented Jun 29, 2015

Agree, there is bug for trait with an accessor method (no parameters) that causes compile error.

@bkkoo
Copy link

bkkoo commented Jun 29, 2015

Currently, I've to make accessor method with empty parenthesis instead. For example :

trait MyInfo {
def myName(): String // that should only be --> def myName:String or val myName:String
}

@oyvindberg
Copy link
Author

Err, so much for actually reading your comment!

Yes, I figured it was mostly possible to use empty parenthesis so work around the problem, this is mostly a big problem for people experimenting with the library, where it's almost impossible to understand what you're doing wrong - I spent a long while making random changes to my source code in order to figure it out.

@oyvindberg
Copy link
Author

So i had a quick look at the macro behind this, and it seems it doesnt work because autowire treats vals as nested traits with methods to expose (if i understand it correctly).

@lihaoyi would it be a better idea to for example tag traits with an annotation? would you be interested if i tried to hack that into working?

@autowireable
trait {
  val x = 42
}

@bkkoo
Copy link

bkkoo commented Jul 8, 2015

@elacin Sorry for my unclear comment. I do not understand about "autowire treats vals as nested traits with methods to expose" but I'm interested in your workaround by using annotation. I'm not scala macro expert and have no time to learn and dig in to autowire source code. Thank you.

@lihaoyi
Copy link
Owner

lihaoyi commented Jul 8, 2015

@lihaoyi would it be a better idea to for example tag traits with an annotation? would you be interested if i tried to hack that into working?

I did that before, I didn't find it that useful.

Unfortunately, I don't have time to look at this right now; I'm making my rounds through my various libraries and current focus is on upickle/ammonite. I'll have something more intelligent to say next time...

marcgrue referenced this issue in marcgrue/autowire May 19, 2020
@marcgrue
Copy link
Contributor

I believe this commit solves this issue

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

4 participants