Skip to content

Inconsitency betwee types and symbols of Idents refering to lifted functions after LambdaLift #342

Closed
@DarkDimius

Description

@DarkDimius
object Test {
  def test2: Int = {
    var ds: String = null
    def s = {
      ds = "abs"
      ds
    }
    s.length
  }

As expected, LambdaLift lifts out def s and ads additional argument to it, creating a method def s$1(ds$1: scala.runtime.ObjectRef): String.

At the end of transformation Ident('s') reference in body of test2 has a fixed symbol s$1, but the type remains TermRef(NoPrefix, s) with a fixed symbol s$1.

As dotty has Idents that are effectively Selects in scalac, backend needs to figure out which reciever to load based on an Ident('s'). This information was expected to come from type, but in this case type is wrong(should be TermRef(This(Test2), s)), and it cannot be recreated from symbol as symbol doesn't indicate an object instance for the method invocation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions