Skip to content

String identifiers yield compilation errors when converted withDottyCompat #3100

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
magnusart opened this issue Sep 11, 2017 · 0 comments · Fixed by #7601
Closed

String identifiers yield compilation errors when converted withDottyCompat #3100

magnusart opened this issue Sep 11, 2017 · 0 comments · Fixed by #7601

Comments

@magnusart
Copy link

I have gotten an unexpected compilation error when setting up a template project to try out dotty and following the Akka documentation at http://doc.akka.io/docs/akka-http/current/scala/http/introduction.html#using-akka-http

I set up the dependencies described and added withDottyCompat to my library dependencies in my build.sbt and also made sure to define crossScalaVersions as per the Dotty example project.

I then get an compilation error for the following line of code:

complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))

The error I get is

[error] -- [E008] Member Not Found Error: /Users/ ... /TestService.scala:27:43
[error] 27 |          complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
[error]    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value `text$u002Fhtml(UTF-8)` is not a member of akka.http.scaladsl.model.ContentTypes

If I change the signature (via content assist) to

complete(HttpEntity(ContentTypes.text$divhtml$u0028UTF$minus8$u0029, "<h1>Say hello to akka-http</h1>"))

Dotty can now compile the project just fine.

smarter added a commit to dotty-staging/dotty that referenced this issue Nov 21, 2019
There were several issues with the scheme we used so far:
- It's different from Scala 2, meaning that some Scala 2 methods could
not be called from Dotty and vice-versa (see the added
sbt-dotty/sbt-test/scala2-compat/akka/i3100.scala test for an example)
- It can lead to invalid filenames on Windows (scala#7492)
- The handling of backticks is broken: adding or removing backticks
around a name changes how it's encoded.

To maintain Scala 2 compat we don't have a lot of choices here, we must
use the same scheme, so this commit aligns NameTransformer.scala with
https://github.com/scala/scala/blob/2.13.x/src/library/scala/reflect/NameTransformer.scala

Fixes scala#3100. Fixes scala#5936. Fixes scala#7492.
smarter added a commit to dotty-staging/dotty that referenced this issue Nov 21, 2019
There were several issues with the scheme we used so far:
- It's different from Scala 2, meaning that some Scala 2 methods could
not be called from Dotty and vice-versa (see the added
sbt-dotty/sbt-test/scala2-compat/akka/i3100.scala test for an example)
- It can lead to invalid filenames on Windows (scala#7492)
- The handling of backticks is broken: adding or removing backticks
around a name changes how it's encoded.

To maintain Scala 2 compat we don't have a lot of choices here, we must
use the same scheme, so this commit aligns NameTransformer.scala with
https://github.com/scala/scala/blob/2.13.x/src/library/scala/reflect/NameTransformer.scala

Fixes scala#3100. Fixes scala#5936. Fixes scala#7492.
smarter added a commit to dotty-staging/dotty that referenced this issue Nov 21, 2019
There were several issues with the scheme we used so far:
- It's different from Scala 2, meaning that some Scala 2 methods could
not be called from Dotty and vice-versa (see the added
sbt-dotty/sbt-test/scala2-compat/akka/i3100.scala test for an example)
- It can lead to invalid filenames on Windows (scala#7492)
- The handling of backticks is broken: adding or removing backticks
around a name changes how it's encoded.

To maintain Scala 2 compat we don't have a lot of choices here, we must
use the same scheme, so this commit aligns NameTransformer.scala with
https://github.com/scala/scala/blob/2.13.x/src/library/scala/reflect/NameTransformer.scala

Fixes scala#3100. Fixes scala#5936. Fixes scala#7492.
smarter added a commit to dotty-staging/dotty that referenced this issue Nov 25, 2019
There were several issues with the scheme we used so far:
- It's different from Scala 2, meaning that some Scala 2 methods could
not be called from Dotty and vice-versa (see the added
sbt-dotty/sbt-test/scala2-compat/akka/i3100.scala test for an example)
- It can lead to invalid filenames on Windows (scala#7492)
- The handling of backticks is broken: adding or removing backticks
around a name changes how it's encoded.

To maintain Scala 2 compat we don't have a lot of choices here, we must
use the same scheme, so this commit aligns NameTransformer.scala with
https://github.com/scala/scala/blob/2.13.x/src/library/scala/reflect/NameTransformer.scala

Some examples:

Method name | Old encoding | New encoding
-----------------------------------------
a_+         |      a_$plus |      a_$plus
`a_+`       |          a_+ |      a_$plus
`+_a`       |          +_a |      $plus_a
a_/         |       a_$div |       a_$div
`a_/`       |     a_$u002F |       a_$div

If a Dotty method is called `def a_$plus` we won't misinterpret it as
`a_+` because the method name comes from the tasty tree which stores
unencoded names. On the other hand, names coming from Java / Scala 2 as
well as top-level classnames might be misinterpreted as encoded names if
they contain a user-written $, this is left unspecified.

Fixes scala#3100. Fixes scala#5936. Fixes scala#7492.
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 a pull request may close this issue.

1 participant