8000 Incorrect LineNumberTable for trait consturctors · Issue #23413 · scala/scala3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Incorrect LineNumberTable for trait consturctors #23413
Open
@SrTobi

Description

@SrTobi

Compiler version

3.7.1

Minimized code

package org.test

trait Test:

  given by_Int: Int = 1

  def mult(x: Int)(using by: Int) = println(x * by)


  mult(3)  // line 10
  mult(4)  // line 11
  mult(5)  // line 12

Output

public interface org.test.Test {
  public static void $init$(org.test.Test);
    Code:
       0: aload_0  // line 10
       1: iconst_3
       2: aload_0
       3: invokeinterface #12,  1           // InterfaceMethod by_Int:()I
       8: invokeinterface #16,  3           // InterfaceMethod mult:(II)V
      13: aload_0  // line 10
      14: iconst_4 // line 11
      15: aload_0  // line 15
      16: invokeinterface #12,  1           // InterfaceMethod by_Int:()I
      21: invokeinterface #16,  3           // InterfaceMethod mult:(II)V
      26: aload_0  // line 10
      27: iconst_5 // line 12
      28: aload_0  // line 10
      29: invokeinterface #12,  1           // InterfaceMethod by_Int:()I
      34: invokeinterface #16,  3           // InterfaceMethod mult:(II)V
      39: return
    LineNumberTable:
      line 10: 0
      line 10: 13
      line 11: 14
      line 10: 15
      line 10: 26
      line 12: 27
      line 10: 28

Expectation

    LineNumberTable:
      line 10: 0
      line 11: 13
      line 12: 26

See for example the output for the same code with class instead of trait:

public class org.test.Test {
  public static final long OFFSET$0;

  public org.test.Test();
    Code:
       0: aload_0  // line 3
       1: invokespecial #27                 // Method java/lang/Object."<init>":()V
       4: aload_0  // line 10
       5: iconst_3
       6: aload_0
       7: invokevirtual #31                 // Method by_Int:()I
      10: invokevirtual #35                 // Method mult:(II)V
      13: aload_0  // line 11
      14: iconst_4
      15: aload_0
      16: invokevirtual #31                 // Method by_Int:()I
      19: invokevirtual #35                 // Method mult:(II)V
      22: aload_0  // line 12
      23: iconst_5
      24: aload_0
      25: invokevirtual #31                 // Method by_Int:()I
      28: invokevirtual #35                 // Method mult:(II)V
      31: return
    LineNumberTable:
      line 3: 0
      line 10: 4
      line 11: 13
      line 12: 22

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0