Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
adpi2 opened this issue Nov 1, 2023 · 0 comments · Fixed by #18840
Closed

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

adpi2 opened this issue Nov 1, 2023 · 0 comments · Fixed by #18840

Comments

@adpi2
Copy link
Member

adpi2 commented Nov 1, 2023

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.

@adpi2 adpi2 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 1, 2023
adpi2 added a commit to adpi2/scala-debug-adapter that referenced this issue Nov 2, 2023
@sjrd sjrd self-assigned this Nov 3, 2023
@sjrd sjrd added area:positions area:transform and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 3, 2023
sjrd added a commit to dotty-staging/dotty that referenced this issue Nov 3, 2023
sjrd added a commit to dotty-staging/dotty that referenced this issue Nov 3, 2023
sjrd added a commit to dotty-staging/dotty that referenced this issue Nov 6, 2023
sjrd added a commit that referenced this issue Nov 6, 2023
adpi2 added a commit to adpi2/scala-debug-adapter that referenced this issue Dec 20, 2023
WojciechMazur pushed a commit that referenced this issue Jul 2, 2024
WojciechMazur added a commit that referenced this issue Jul 3, 2024
…ullyParameterizedDef`." to LTS (#20966)

Backports #18840 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants