Skip to content

Slow compilation of chained applyDynamic #16544

Closed
@prolativ

Description

@prolativ

Compiler version

3.2.1 and before

Minimized code

import scala.language.dynamics

object Foo extends Dynamic {
  def applyDynamic(name: String)(): Foo.type = this
}

object Test {
  def test() = {
    Foo
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
      .xxx()
  }
}

Output

This compiles successfully but the compilation time starts to rapidly grow (nonlinearly?) starting from some number of chained invocations desugared to applyDynamic. This happens also for applyDynamicNamed.

Expectation

In scala 2.13 this compiles almost instantly so compilation times should not explode in scala 3 either

Metadata

Metadata

Assignees

Labels

area:desugarDesugaring happens after parsing but before typing, see desugar.scalaitype:performance

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions