Generate inline site's file name in metadata
Otherwise, stacktraces will have invalid file name (declaration site). #KT-30508 Fixed
This commit is contained in:
@@ -133,7 +133,6 @@ class AnonymousObjectTransformer(
|
||||
val coroutineTransformer = CoroutineTransformer(
|
||||
inliningContext,
|
||||
classBuilder,
|
||||
sourceInfo,
|
||||
methodsToTransform,
|
||||
superClassName
|
||||
)
|
||||
|
||||
+2
-3
@@ -26,7 +26,6 @@ import org.jetbrains.org.objectweb.asm.tree.TypeInsnNode
|
||||
class CoroutineTransformer(
|
||||
private val inliningContext: InliningContext,
|
||||
private val classBuilder: ClassBuilder,
|
||||
private val sourceFile: String?,
|
||||
private val methods: List<MethodNode>,
|
||||
private val superClassName: String
|
||||
) {
|
||||
@@ -111,7 +110,7 @@ class CoroutineTransformer(
|
||||
shouldPreserveClassInitialization = state.constructorCallNormalizationMode.shouldPreserveClassInitialization,
|
||||
containingClassInternalName = classBuilder.thisName,
|
||||
isForNamedFunction = false,
|
||||
sourceFile = sourceFile ?: "",
|
||||
sourceFile = element.containingKtFile.name,
|
||||
isCrossinlineLambda = inliningContext.isContinuation
|
||||
)
|
||||
}
|
||||
@@ -140,7 +139,7 @@ class CoroutineTransformer(
|
||||
isForNamedFunction = true,
|
||||
needDispatchReceiver = true,
|
||||
internalNameForDispatchReceiver = classBuilder.thisName,
|
||||
sourceFile = sourceFile ?: ""
|
||||
sourceFile = element.containingKtFile.name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
// FILE: flow.kt
|
||||
package flow
|
||||
|
||||
interface FlowCollector<T> {
|
||||
suspend fun emit(value: T)
|
||||
}
|
||||
|
||||
interface Flow<T : Any> {
|
||||
suspend fun collect(collector: FlowCollector<T>)
|
||||
}
|
||||
|
||||
public inline fun <T : Any> flow(crossinline block: suspend FlowCollector<T>.() -> Unit): Flow<T> = object : Flow<T> {
|
||||
override suspend fun collect(collector: FlowCollector<T>) = collector.block()
|
||||
}
|
||||
|
||||
inline suspend fun <T : Any> Flow<T>.collect(crossinline action: suspend (T) -> Unit): Unit =
|
||||
collect(object : FlowCollector<T> {
|
||||
override suspend fun emit(value: T) = action(value)
|
||||
})
|
||||
|
||||
// FILE: Test.kt
|
||||
|
||||
import flow.*
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var str = "FAIL"
|
||||
builder {
|
||||
flow<Unit> {
|
||||
var continuation: Continuation<Unit>? = null
|
||||
suspendCoroutineUninterceptedOrReturn<Unit> { continuation = it; Unit }
|
||||
str = "$continuation"
|
||||
}.collect {
|
||||
}
|
||||
}
|
||||
if ("(Test.kt:" !in str) return str
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -3425,6 +3425,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("fileNameInMetadata.kt")
|
||||
public void testFileNameInMetadata() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/suspend/fileNameInMetadata.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineOrdinaryOfCrossinlineSuspend.kt")
|
||||
public void testInlineOrdinaryOfCrossinlineSuspend_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfCrossinlineSuspend.kt", "kotlin.coroutines.experimental");
|
||||
|
||||
Generated
+5
@@ -3425,6 +3425,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("fileNameInMetadata.kt")
|
||||
public void testFileNameInMetadata() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/suspend/fileNameInMetadata.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineOrdinaryOfCrossinlineSuspend.kt")
|
||||
public void testInlineOrdinaryOfCrossinlineSuspend_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfCrossinlineSuspend.kt", "kotlin.coroutines.experimental");
|
||||
|
||||
+5
@@ -3425,6 +3425,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("fileNameInMetadata.kt")
|
||||
public void testFileNameInMetadata() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/suspend/fileNameInMetadata.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineOrdinaryOfCrossinlineSuspend.kt")
|
||||
public void testInlineOrdinaryOfCrossinlineSuspend_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfCrossinlineSuspend.kt", "kotlin.coroutines.experimental");
|
||||
|
||||
Reference in New Issue
Block a user