Skip to content

Alias givens don't forward the reference for simple expressions #16191

@kyri-petrou

Description

@kyri-petrou

Compiler version

3.1.3 / 3.2.0 / 3.2.1-RC2

Minimized code

class Context

val ctx: Context = new Context
given Context = ctx

Output

Compiler output using -Xprint:typer:

package <empty> {
  class Context() extends Object() {}
  final lazy module val Main$package: Main$package = new Main$package()
  final module class Main$package() extends Object() { 
    this: Main$package.type =>
    val ctx: Context = new Context()
    final lazy given val given_Context: Context = ctx
  }
}

Expectation

According to the documentation, the given in the example above should forward the reference instead of caching it. i.e.,

final lazy given val given_Context: Context = ctx

should map to

final given def given_Context: Context = ctx

Is this an issue with the documentation, the compiler or am I misinterpreting the documentation?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions