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

fix: correctly insert type annotation in tuples lambda args #4859

Merged
merged 2 commits into from Jan 17, 2023

Conversation

jkciesluk
Copy link
Member

@jkciesluk jkciesluk commented Jan 13, 2023

fixes #4849
Previously

List((1,2)).map((<<a>>,b) => a)
// would insert type here
List((1,2)).map((a,b) => a: Int)

This happened because tuple argument symbols don't have Param flag (probably connected to scala/scala3#16110) Now we have different way to check if we are on parameter

Previously
```scala
List((1,2)).map((<<a>>,b) => a)
// would insert type here
List((1,2)).map((a,b) => a: Int)
```
This happened because tuple argument symbols don't have `Param` flag
(probably connected to scala/scala3#16110)
Now we have different way to check if we are on parameter
@@ -236,7 +241,10 @@ final class InferredTypeProvider(
*/
case Some(df @ DefDef(name, _, tpt, rhs)) =>
def typeNameEdit =
val end = tpt.endPos.toLsp
val end =
Copy link
Member Author

@jkciesluk jkciesluk Jan 13, 2023

Choose a reason for hiding this comment

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

In scala 3.1.3,

List((1,2)).map((<<a>>,b) => ...) //results in
List((1,2)).map((:Inta,b) => ...)

a and b are treated as methods, but their tpt.SourcePos == df.namePos.startPos, so we need this correctly insert type after name

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Great work! Just a minor comment.

Co-authored-by: Tomasz Godzik <tgodzik@users.noreply.github.com>
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM!

@tgodzik tgodzik merged commit 6068f23 into scalameta:main Jan 17, 2023
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.

Incorrect Insert type annotation codeaction for lambdas
2 participants