diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-05-31 09:45:10 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-06-06 14:37:47 +1000 |
commit | 2980c3921f1270f05add25239da93e05f64ad45f (patch) | |
tree | 275352bfc451352cf9ecd9761b7da4ad18858349 /src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala | |
parent | e1084299350bcc20f5d412993d77b8f956ba3165 (diff) | |
download | scala-2980c3921f1270f05add25239da93e05f64ad45f.tar.gz scala-2980c3921f1270f05add25239da93e05f64ad45f.tar.bz2 scala-2980c3921f1270f05add25239da93e05f64ad45f.zip |
Keep line numbers when inlining from the same compilation unit
So far, line numbers were kept only when inlining from the same class.
We can also keep them when inlining from a different class defined in
the same compilation unit.
Longer-term we should support JSR-45, see SI-7518 and scala-dev#3.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala index d18963ec8b..7b4cfe2a18 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala @@ -253,7 +253,7 @@ class Inliner[BT <: BTypes](val btypes: BT) { def inlineCallsite(callsite: Callsite): Unit = { import callsite.{callsiteClass, callsiteMethod, callsiteInstruction, receiverKnownNotNull, callsiteStackHeight} val Right(callsiteCallee) = callsite.callee - import callsiteCallee.{callee, calleeDeclarationClass} + import callsiteCallee.{callee, calleeDeclarationClass, sourceFilePath} // Inlining requires the callee not to have unreachable code, the analyzer used below should not // return any `null` frames. Note that inlining a method can create unreachable code. Example: @@ -268,7 +268,14 @@ class Inliner[BT <: BTypes](val btypes: BT) { // New labels for the cloned instructions val labelsMap = cloneLabels(callee) - val (clonedInstructions, instructionMap, hasSerializableClosureInstantiation) = cloneInstructions(callee, labelsMap, keepLineNumbers = callsiteClass == calleeDeclarationClass) + val sameSourceFile = sourceFilePath match { + case Some(calleeSource) => byteCodeRepository.compilingClasses.get(callsiteClass.internalName) match { + case Some((_, `calleeSource`)) => true + case _ => false + } + case _ => false + } + val (clonedInstructions, instructionMap, hasSerializableClosureInstantiation) = cloneInstructions(callee, labelsMap, keepLineNumbers = sameSourceFile) // local vars in the callee are shifted by the number of locals at the callsite val localVarShift = callsiteMethod.maxLocals |