question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type annotations make the pretty-printed tree quadratically large

See original GitHub issue
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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
allanrenuccicommented, Jun 19, 2018

We should still fix the printer

0reactions
allanrenuccicommented, Jul 20, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's New In Python 3.10 — Python 3.11.1 documentation
It works around the quirks of accessing the annotations on various types of objects, and makes very few assumptions about the object it...
Read more >
Type Hints in Python: What, Why, and How - YouTube
In this video I talk about annotating your functions and variables with type hints in Python and why you should do it.Need one-on-one...
Read more >
Type Annotations in Python 3.8 - Medium
One reason why Python is so easy to get started with is that it has dynamic types. You don't have to specify the...
Read more >
pretty :: Stackage Server
Pretty : A Haskell Pretty-printer library. Hackage Dependencies · BSD3 License · Build. Pretty is a pretty-printing library, a set of API's that...
Read more >
Python Programming Examples - Javatpoint
Python Programs or Python Programming Examples for beginners and professionals with programs on basics, controls, loops, functions, native data types etc.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found