Skip to content

Wrong debug line in a local method of a value class that captures a using instance #18816

Closed
@adpi2

Description

@adpi2

Compiler version

3.3.1

Minimized code

//> using scala 3.3.1

package example

trait Context

class A(x: Context) extends AnyVal:
  given [T]: Context = x

  def m1 =
    println(m3) // line 11
    def m2 =
      m3 // line 13
    println(m2)

  def m3(using Context): String = ""

Output

The javap of example.A$ contains:

  private final java.lang.String m2$1(example.Context);
    descriptor: (Lexample/Context;)Ljava/lang/String;
    flags: ACC_PRIVATE, ACC_FINAL
    Code:
      stack=4, locals=2, args_size=2
         0: aload_0
         1: aload_1
         2: aload_0
         3: aload_1
         4: invokevirtual #61                 // Method given_Context$extension:(Lexample/Context;)Lexample/Context;
         7: invokevirtual #65                 // Method m3$extension:(Lexample/Context;Lexample/Context;)Ljava/lang/String;
        10: areturn
      LineNumberTable:
        line 13: 0
        line 11: 1
        line 13: 2
        line 11: 3
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      11     0  this   Lexample/A$;
            0      11     1 $this$1   Lexample/Context;
    MethodParameters:
      Name                           Flags
      $this$1                        final

Expectation

The debug line table of m2$1 should not contain line 11 which is outside of m2 span.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions