Skip to content

fix #SCL-23707 #677

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

Closed

Conversation

Alex1005a
Copy link
Contributor

@Alex1005a Alex1005a commented Mar 23, 2025

To fix the problem I had to change the parsing of interpolated string. I'm not sure if it's correct, but I couldn't find another way.

https://youtrack.jetbrains.com/issue/SCL-23707

@unkarjedy
Copy link
Member

unkarjedy commented Mar 29, 2025

Thank you for the contribution and sorry for the late reply!
Please add tests to all the effected subsystems (in this case parser, parameter info, annotator/type inference (original issue is the red code))

@unkarjedy
Copy link
Member

I don't think that changing the parser is needed here.
It also goes against Scala definition of what Scala interpolated string is
https://docs.scala-lang.org/scala3/reference/syntax.html

@Alex1005a
Copy link
Contributor Author

Yes, from the specification point of view it is not correct. I did it this way because interpolated string is parsed first into an intermediate structure, and not immediately desugar as in the scala compiler. Desugaring occurs in the desugaredExpression method, and if no arguments are passed to the function from interpolator during it, the type check will fail.
There is probably a more correct way to do this, but I don't know about it, since I am not very familiar with the code base and the project architecture.

@unkarjedy unkarjedy requested a review from SrTobi May 5, 2025 10:09
@SrTobi
Copy link
Contributor

SrTobi commented May 13, 2025

@Alex1005a hi. Thanks for your PR. I used the tests, but ended up not using your implementation. The syntax tree that was generated was already correct. The problem was more that the annotator couldn't handle the de-sugaring correctly. That's why you pulled the arguments into the desugaring. This didn't help with some other cases, though, like

implicit class CustomInterpolator(private val stringContext: StringContext) {
  def test(values: Any*)(i: Int): Unit = {}
}

// this was still annotated as missing a parameter list, although the compiler allows this
val x = test"" // type of x is then Int => Unit

// you would expect the compiler to complain and demand something like
val x = test"" _
// but that is not the case ¯\_(ツ)_/¯

In the end I just tweaked the annotator a little bit to be aware of the de-sugaring and disable missing-parameter clauses for interpolated string literals altogether 😁

I merged it manually, so this PR can be closed. Thanks again 👍

@SrTobi SrTobi closed this May 13, 2025
@Alex1005a Alex1005a deleted the idea251.x-fix-scl-23707 branch May 22, 2025 19:16
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