Skip to content

Dotty's name encoding scheme does not match Scala 2 in some situations #5936

Closed
@smarter

Description

@smarter

Given:

class A {
  def a_+(): Unit = {}
  def `+_a`(): Unit = {}
}

Dotty generates methods:

   public void a_$plus()
   public void +_a()

Whereas Scala 2 generates:

  public void a_$plus()
  public void $plus_a()

I was about to fix this but the comment above NameTransformer#encode written by @odersky suggests that this is intentional: https://github.com/lampepfl/dotty/blob/12eef6d8e51dcd8a9a73387659b0f860d7b9ca80/compiler/src/dotty/tools/dotc/util/NameTransformer.scala#L87-L88

@odersky Is being different from Scala 2 actually intended here ? This makes it impossible to call some Scala 2 methods from Dotty (we may want to change the name encoding scheme, but only if we get Scala 2 to change it in lockstep with us).

Marked as a blocker for the release because upgrading to ASM 7 lead to a name-encoding-related issue: #5917 (comment), I know how to fix it but the fix interacts with the current semantics of encode and I'd like to get some clarity here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions