Skip to content

Fix #8531: Annnotations on class value parameters go to the constructor #8534

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 3 commits into from
Apr 6, 2020

Conversation

smarter
Copy link
Member

@smarter smarter commented Mar 12, 2020

Mimic the behavior of Scala 2: an annotation on a class value
parameters (but not on a type parameter) is moved to the constructor
parameter and not to any of the derived parameters.

@smarter smarter force-pushed the constr-param-annot branch 2 times, most recently from 361d078 to 94362b7 Compare March 12, 2020 23:22
This annotation used to be called @transientParam but that's no longer
the case.
@smarter smarter force-pushed the constr-param-annot branch from 94362b7 to 6163f77 Compare April 4, 2020 17:11
smarter added a commit to dotty-staging/shapeless that referenced this pull request Apr 4, 2020
…onstructor

...and not to the fields. This matches the behavior of Scala 2.

See scala/scala3#8534.
@smarter smarter force-pushed the constr-param-annot branch from 6163f77 to 025bb1f Compare April 4, 2020 17:13
@smarter
Copy link
Member Author

smarter commented Apr 4, 2020

/cc @milessabin This PR required a small change in shapeless: dotty-staging/shapeless@d41323c. Once this is merged and a new nightly is published, I could make a PR against your shapeless-3 branch to get this upstream, would that be convenient for you ?

@smarter smarter requested a review from odersky April 4, 2020 18:09
@smarter smarter assigned odersky and unassigned smarter Apr 4, 2020
smarter added 2 commits April 4, 2020 20:10
…tructor

Mimic the behavior of Scala 2: an annotation on a class value
parameters (but not on a type parameter) is moved to the constructor
parameter and not to any of the derived parameters.

This required adapting the semanticdb extractor to go look for
annotations in constructor parameters too.
Also added `primaryConstructor` to the reflection API for convenience.
@smarter smarter force-pushed the constr-param-annot branch from 025bb1f to f5e2f1b Compare April 4, 2020 18:10
@smarter
Copy link
Member Author

smarter commented Apr 5, 2020

@odersky @nicolasstucki The signature of paramSymss is:

def paramSymss(using ctx: Context): (List[TypeSymbol], List[List[TermSymbol]])

This assumes that we only have one type parameter list which might not be correct in the future, this is especially problematic since we're exposing this API via tasty-reflect, so we need something future-proof. I suggest:

def paramSymss(using ctx: Context): List[List[Symbol]]

@smarter
Copy link
Member Author

smarter commented Apr 6, 2020

def paramSymss(using ctx: Context): List[List[Symbol]]

We agreed to this in a meeting, I'll do the change.

@milessabin
Copy link
Contributor

@smarter

Once this is merged and a new nightly is published, I could make a PR against your shapeless-3 branch to get this upstream, would that be convenient for you ?

💯

@odersky odersky merged commit eff5496 into scala:master Apr 6, 2020
@odersky odersky deleted the constr-param-annot branch April 6, 2020 17:42
milessabin pushed a commit to milessabin/shapeless that referenced this pull request Apr 10, 2020
…onstructor

...and not to the fields. This matches the behavior of Scala 2.

See scala/scala3#8534.
@milessabin
Copy link
Contributor

@smarter I've updated shapeless here: #8705.

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