Skip to content
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

Type annotations make the pretty-printed tree quadratically large #4678

Closed
nicolasstucki opened this issue Jun 18, 2018 · 5 comments
Closed

Comments

@nicolasstucki
Copy link
Contributor

class Foo {
  val x: Int = (1: @annot1 @annot2 @annot3 @annot4 @annot5)
}

class annot1 extends scala.annotation.Annotation
class annot2 extends scala.annotation.Annotation
class annot3 extends scala.annotation.Annotation
class annot4 extends scala.annotation.Annotation
class annot5 extends scala.annotation.Annotation

types the code as

result of Foo.scala after frontend:
package <empty> {
  class Foo() extends Object() { 
    val x: Int = 
      1: Int(1) @annot1: Int(1) @annot1 @annot2: Int(1) @annot1 @annot2 @annot3
        : 
      Int(1) @annot1 @annot2 @annot3 @annot4: 
        Int(1) @annot1 @annot2 @annot3 @annot4 @annot5
  }
  ...
}

where we should have

val x: Int = 1: Int(1) @annot1 @annot2 @annot3 @annot4 @annot5
@smarter
Copy link
Member

smarter commented Jun 19, 2018

The pretty-printed tree is quadratic but is the actual raw tree that way too?

@nicolasstucki
Copy link
Contributor Author

You are right. There is one tree per annotation.

@allanrenucci
Copy link
Contributor

We should still fix the printer

@Blaisorblade Blaisorblade reopened this Jun 19, 2018
@Blaisorblade Blaisorblade changed the title Type annotations make the tree quadratically large Type annotations make the pretty-printed tree quadratically large Jun 19, 2018
@manshengyang
Copy link

I have a fix for this, any idea where to put the test?

@allanrenucci
Copy link
Contributor

You could add a test to dotty.tools.dotc.printing.PrinterTests

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 15, 2019
…notations

This is mostly useful for printers as it represents what is witten in the source.
I may also slightly improve performance of later phases.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 15, 2019
…notations

This is mostly useful for printers as it represents what is written in the source.
I may also slightly improve performance of later phases.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 15, 2019
This is mostly useful for printers as it represents what is written in the source.
I may also slightly improve performance of later phases.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 15, 2019
This is mostly useful for printers as it represents what is written in the source.
I may also slightly improve performance of later phases.
smarter added a commit that referenced this issue Jan 16, 2019
Fix #4678: Create single Typed tree with multiple type annotations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants