Dotty: Type annotations make the pretty-printed tree quadratically large

Created on 18 Jun 2018  路  5Comments  路  Source: lampepfl/dotty

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
annotations help wanted bug fix available

Most helpful comment

We should still fix the printer

All 5 comments

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

You are right. There is one tree per annotation.

We should still fix the printer

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lihaoyi picture lihaoyi  路  30Comments

sstucki picture sstucki  路  30Comments

neko-kai picture neko-kai  路  39Comments

odersky picture odersky  路  45Comments

felixmulder picture felixmulder  路  120Comments