Skip to content

Slow compilation of chained applyDynamic #16544

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
prolativ opened this issue Dec 16, 2022 · 0 comments · Fixed by #16552
Closed

Slow compilation of chained applyDynamic #16544

prolativ opened this issue Dec 16, 2022 · 0 comments · Fixed by #16552
Assignees
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala itype:performance
Milestone

Comments

@prolativ
Copy link
Contributor

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

@prolativ prolativ added itype:performance area:desugar Desugaring happens after parsing but before typing, see desugar.scala labels Dec 16, 2022
@nicolasstucki nicolasstucki self-assigned this Dec 19, 2022
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2022
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2022
little-inferno pushed a commit to little-inferno/dotty that referenced this issue Jan 25, 2023
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala itype:performance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants