Skip to content

Inline methods with by-name arguments break debugging information #4947

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

Closed
Blaisorblade opened this issue Aug 15, 2018 · 6 comments
Closed

Comments

@Blaisorblade
Copy link
Contributor

In the snippet below, setting breakpoints in isSubType is hard if it's compiled by Dotty, because all of isSubType appears written on line 100.

transparent def track(f: => T): T = { ... f ... }

def isSubType(...) = track { // line 100
  body
]

Probably should be addressed before bootstrap, hence tentatively targeting milestone 0.10.

@Blaisorblade
Copy link
Contributor Author

@odersky can you take a look?

@nicolasstucki
Copy link
Contributor

The same issue happens at runtime with the stack trace

object Foo {
  transparent def track[T](f: => T): T = f

  def main(args: Array[String]): Unit = {
    track {
      val a = 9
      ???
    }
  }

}
Exception in thread "main" scala.NotImplementedError: an implementation is missing
	at scala.Predef$.$qmark$qmark$qmark(Predef.scala:284)
	at Foo$.main(Foo.scala:5)
	at Foo.main(Foo.scala)

@smarter
Copy link
Member

smarter commented Aug 15, 2018

@nicolasstucki That's a separate (and much harder to solve) issue, if your code is inlined in a method, you can't have the stacktrace show the methods that have been inlined. JSR-45 (that the Scala Center was supposed to implement) should help in theory but I don't think it's used for stacktraces.

@smarter
Copy link
Member

smarter commented Aug 15, 2018

Actually JSR-45 is relevant for the original issue from @Blaisorblade too: without implementing it, there is no way to preserve line information for debugging when inlining across files.

@nicolasstucki
Copy link
Contributor

No, in this case we lose the position of code that was in the current method (not inlined code). The position of the tree of ??? should not be lost while inlining it in the code of track.

@nicolasstucki
Copy link
Contributor

The position is changed in erasure when the Inline tree is dropped.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 15, 2018
Blaisorblade added a commit that referenced this issue Aug 24, 2018
Fix #4947: Do not replace positions of inlined arguments
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants