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

bugfix: don't show inferred type for val def bind #5891

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

kasiaMarek
Copy link
Contributor

@kasiaMarek kasiaMarek commented Nov 29, 2023

resolves: #5835

There seems to be no reasonable way to distinguish t from t1 in val t @ (t1, t2,) = (1,2) in typed trees. We could do this on untyped but I think it will be faster this way.

@kasiaMarek kasiaMarek marked this pull request as ready for review November 30, 2023 10:27
Copy link
Member

@jkciesluk jkciesluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we don't have to use vd.source.content() but this is fine

* val <<t>> @ ... =
*/
private def isValDefBind(vd: ValDef)(using Context) =
val (_, afterDef) = vd.source.content().splitAt(vd.nameSpan.end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val (_, afterDef) = vd.source.content().splitAt(vd.nameSpan.end)
val afterDef = text.drop(vd.namePosition.end)

* val <<t>> @ ... =
*/
private def isValDefBind(vd: ValDef) = {
val (_, afterDef) = vd.pos.source.content.splitAt(vd.namePosition.end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can move it to PcSyntheticDecorationsProvider so we can use text instead of pos.source.content?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to move it for Scala 3, I'd have to pattern match to see it's a ValDef, and it's a bit inconsistent. I added a given for Scala 3 instead (with an opaque type). What do you think? Too much hassle?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine

@kasiaMarek kasiaMarek merged commit 02ab6b7 into scalameta:main Dec 1, 2023
24 of 25 checks passed
tgodzik added a commit to scala/scala3 that referenced this pull request Jan 17, 2024
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.

Synthetic decorations on val with unapply
3 participants