Skip to content

Lifted anonymous classes clash with non anonymous ones #3051

@nicolasstucki

Description

@nicolasstucki
class Foo {
  class $anon$1
  new Object { }
}

As the unique name generator does not know about the name on class $anon$1, it will give the same name to the class for new Object { }. The result is a corrupted scope where both names refer to the same symbol and get stuck in an infinite loop.

Same for methods

class Foo {
  def foo = {
    def f() = ()
    f()
  }
  def f$1() = ()
}

There are two possible solutions

  • Disallow names
  • Register all relevant names for classes and methods in the map of the FreshNameCreator

Which one should we choose? I am more inclined to the first one as it simplifies the interaction with #2999

scalac has the same issue scala/bug#10492

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions