Skip to content

positions incorrect for this references in traits #186

Closed
@retronym

Description

@retronym
package p1
trait C {
  def test = {
    val c = 1
    try {
      toString
    } finally {
      toString
    }
  }
}

 public static java.lang.String test$(p1.C);
    descriptor: (Lp1/C;)Ljava/lang/String;
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=3, args_size=1
         0: iconst_1
         1: istore_1
         2: aload_0
         3: invokevirtual #15                 // Method java/lang/Object.toString:()Ljava/lang/String;
         6: goto          17
         9: astore_2
        10: aload_0
        11: invokevirtual #15                 // Method java/lang/Object.toString:()Ljava/lang/String;
        14: pop
        15: aload_2
        16: athrow
        17: aload_0
        18: invokevirtual #15                 // Method java/lang/Object.toString:()Ljava/lang/String;
        21: pop
        22: areturn
      Exception table:
         from    to  target type
             2     9     9   any
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            1      21     1     c   I
            0      23     0 $this   Lp1/C;
      LineNumberTable:
        line 4: 0
        line 3: 2
        line 3: 10
        line 8: 15
        line 3: 17
        line 8: 22

Looks good if we make it private:

  private java.lang.String test();
    descriptor: ()Ljava/lang/String;
    flags: ACC_PRIVATE
    Code:
      stack=2, locals=3, args_size=1
         0: iconst_1
         1: istore_1
         2: aload_0
         3: invokevirtual #13                 // Method java/lang/Object.toString:()Ljava/lang/String;
         6: goto          17
         9: astore_2
        10: aload_0
        11: invokevirtual #13                 // Method java/lang/Object.toString:()Ljava/lang/String;
        14: pop
        15: aload_2
        16: athrow
        17: aload_0
        18: invokevirtual #13                 // Method java/lang/Object.toString:()Ljava/lang/String;
        21: pop
        22: areturn
      Exception table:
         from    to  target type
             2     9     9   any
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            1      21     1     c   I
            0      23     0  this   Lp1/C;
      LineNumberTable:
        line 4: 0
        line 6: 2
        line 8: 10

so I suspect the problem stems from some detail about positions when we split the method into the test/test$ pair in the backend.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions