Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
inliner bug
➜ sandbox git:(opt/heuristicsPerf) ✗ cat A.scala
object A {
@inline def inner: String = try { throw null } catch { case _: NullPointerException => "npe" }
def foo = try inner catch { case e: Throwable => throw e }
def main(args: Array[String]): Unit = {
println(foo)
}
}
➜ sandbox git:(opt/heuristicsPerf) ✗ qsc A.scala && qs A
npe
➜ sandbox git:(opt/heuristicsPerf) ✗ qsc -Yopt:l:classpath A.scala && qs A
java.lang.NullPointerException
at A$.foo(A.scala:2)
at A$.main(A.scala:6)
➜ sandbox git:(opt/heuristicsPerf) ✗ asm -a A\$.class
➜ sandbox git:(opt/heuristicsPerf) ✗ cat A\$.asm
[...]
// access flags 0x1
public foo()Ljava/lang/String;
TRYCATCHBLOCK L0 L1 L2 java/lang/Throwable
TRYCATCHBLOCK L3 L4 L4 java/lang/NullPointerException
L0
LINENUMBER 3 L0
ALOAD 0
ASTORE 2
L3
LINENUMBER 2 L3
ACONST_NULL
ATHROW
L4
FRAME FULL [A$ T A$] [java/lang/NullPointerException]
POP
LDC "npe"
ASTORE 3
ALOAD 3
L1
ARETURN
L2
FRAME FULL [A$] [java/lang/Throwable]
ASTORE 1
ALOAD 1
ATHROW
L5
LOCALVARIABLE e Ljava/lang/Throwable; L2 L5 1
LOCALVARIABLE this LA$; L0 L5 0
MAXSTACK = 1
MAXLOCALS = 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment