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.

Trees after typer losing information

See original GitHub issue

Compiler version

3.1.3

Minimized code

object Main {
  def foo: ArrayBuffer[Int] = ???
}

ArrayBuffer is missing from imports.

Output

Parser tree

PackageDef(
  pid = Ident(name = <empty>),
  stats = List(
    ModuleDef(
      name = Main,
      impl = Template(
        constr = DefDef(
          name = <init>,
          paramss = List(),
          tpt = TypeTree,
          preRhs = Thicket(trees = List())
        ),
        parentsOrDerived = List(),
        self = ValDef(name = _, tpt = Thicket(trees = List()), preRhs = Thicket(trees = List())),
        preBody = List(
          DefDef(
            name = foo,
            paramss = List(),
            tpt = AppliedTypeTree(tpt = Ident(name = ArrayBuffer), args = List(Ident(name = Int))),
            preRhs = Ident(name = ???)
          )
        )
      )
    )
  )
)

Notice tpt = AppliedTypeTree(tpt = Ident(name = ArrayBuffer), args = List(Ident(name = Int))), <- AppliedTypeTree is available.

Typed tree though:

 tree = TypeDef(
        name = Main$,
        rhs = Template(
          constr = DefDef(
            name = <init>,
            paramss = List(List()),
            tpt = TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],
            preRhs = Thicket(trees = List())
          ),
          parentsOrDerived = List(
            Apply(
              fun = Select(
                qualifier = New(
                  tpt = TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object)]
                ),
                name = <init>
              ),
              args = List()
            )
          ),
          self = ValDef(
            name = _,
            tpt = SingletonTypeTree(ref = Ident(name = Main)),
            preRhs = Thicket(trees = List())
          ),
          preBody = List(
            DefDef(
              name = foo,
              paramss = List(),
              tpt = Ident(name = ArrayBuffer),
              preRhs = Ident(name = ???)
            )
          )
        )
      ),

Notice that the tpt of the DefDef is tpt = Ident(name = ArrayBuffer),

Seems that if the type is not available then we are missing TypeApply, which is useful for the IDE to figure out if we need to insert []

Expectation

TypeApply should still be available in tpt of DefDef. It might be an error type, but it should be available there.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tgodzikcommented, Aug 5, 2022

@dwijnand Seems like that did the trick! Thanks! https://github.com/lampepfl/dotty/pull/15825

0reactions
vzmerrcommented, Jul 27, 2022

I invite you to take a look at the problem this issue has caused in Metals, for the detection of existing type parameters, so that an extra type bracket is not inserted upon type completion. https://github.com/scalameta/metals/pull/4174#discussion_r930605632

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can these trees be saved? Tree recovery after a storm-Tree ...
Some trees simply can't be saved or are not worth saving. If the tree has already been weakened by disease, if the trunk...
Read more >
Decision tree pruning - Wikipedia
Pruning is a data compression technique in machine learning and search algorithms that reduces the size of decision trees by removing sections of...
Read more >
Why Are My Trees Shedding or Losing Leaves in Spring?
For some trees, spring leaf drop is perfectly normal, ... Fortunately, most tree types–including ash– can easily shake off anthracnose.
Read more >
Lost trees, booster benefits — the week in infographics - Nature
Nearly one-third of tree species are threatened with extinction. This is more than twice the number of threatened mammals, birds, ...
Read more >
Why deforestation matters—and what we can do to stop it
A movement is under way to preserve existing forest ecosystems and restore lost tree cover by first reforesting (replanting trees) and ...
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