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

Line nums in stack trace with extension method and delayed init #7594

Closed
scabug opened this Issue Jun 19, 2013 · 2 comments

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented Jun 19, 2013

A test class App loses line number specificity when exception is thrown from value class. Both DelayedInit and AnyVal are required for symptom.

object Test2 extends App {
  implicit class Averrable(val b: Boolean) extends AnyVal {
    def yes = assert(b)
    def no = assert(!b)
  }
  // normal line number
  // at gline.Test2$delayedInit$body.apply(gline.scala:19)
  //throw new RuntimeException

  // line number is start of object Test
  //at scala.Predef$.assert(Predef.scala:165)
  //at gline.Test2$Averrable$.yes$extension(gline.scala:16)
  //at gline.Test2$delayedInit$body.apply(gline.scala:14)
  false.yes

  // same in new encoding
  //at gline.Test2$Averrable$.yes$extension(gline.scala:16)
  //at gline.Test2$.delayedEndpoint$gline$Test2$1(gline.scala:14)
  //at gline.Test2$delayedInit$body.apply(gline.scala:14)
}

And javap says:

  public final void delayedEndpoint$gline$Test2$1();
    flags: ACC_PUBLIC, ACC_FINAL
    Code:
      stack=3, locals=1, args_size=1
         0: getstatic     #65                 // Field gline/Test2$Averrable$.MODULE$:Lgline/Test2$Averrable$;
         3: aload_0       
         4: iconst_0      
         5: invokevirtual #67                 // Method Averrable:(Z)Z
         8: invokevirtual #71                 // Method gline/Test2$Averrable$.yes$extension:(Z)V
        11: return        
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
               0      12     0  this   Lgline/Test2$;
      LineNumberTable:
        line 13: 0
        line 26: 3
        line 13: 8
@scabug

This comment has been minimized.

Copy link

scabug commented Jun 19, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7594?orig=1
Reporter: @som-snytt
Affected Versions: 2.10.1, 2.11.0-M3

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 9, 2016

@som-snytt said:
Progressed in 2.12. Test at scala/scala#5221

@scabug scabug closed this Jun 9, 2016

@scabug scabug added the quickfix label Apr 7, 2017

@scabug scabug added this to the 2.12.0-M2 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment