[JVM] Rewrite isCallInsideSameModuleAsCallee
Try to use `IrModuleFragment` instead of `ModuleDescriptor`. This change is required for the evaluate expression in IDE. When we compile some code fragment with inline function call that has an anonymous object in callee, we will get incorrect behavior. Code fragment is wrapped in `EvaluatorModuleDescriptor` and we accidentally think that inline call and callee are in different modules that leads to an error in `AnonymousObjectTransformer.doTransform`. #KT-63454 Fixed
This commit is contained in:
+19
-1
@@ -106,7 +106,25 @@ class IrSourceCompilerForInline(
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
override val isCallInsideSameModuleAsCallee: Boolean
|
||||
get() = callee.module == codegen.irFunction.module
|
||||
get() {
|
||||
val inlineFunModule = callee.fileOrNull?.module
|
||||
val currentlyGeneratedFunModule = codegen.irFunction.fileOrNull?.module
|
||||
check(currentlyGeneratedFunModule != null) {
|
||||
"There is no module for function ${codegen.irFunction.name}:\n${codegen.irFunction.render()}"
|
||||
}
|
||||
|
||||
return if (inlineFunModule == null) {
|
||||
callee.module == codegen.irFunction.module
|
||||
} else {
|
||||
// Check by IR is needed for the evaluate expression in IDE.
|
||||
// When we compile some code fragment with inline function call
|
||||
// that has an anonymous object in callee, we will get incorrect behavior.
|
||||
// Code fragment is wrapped in `EvaluatorModuleDescriptor` and we accidentally
|
||||
// think that inline call and callee are in different modules that leads to an error in
|
||||
// `AnonymousObjectTransformer.doTransform`.
|
||||
inlineFunModule == currentlyGeneratedFunModule
|
||||
}
|
||||
}
|
||||
|
||||
override val isFinallyMarkerRequired: Boolean
|
||||
get() = codegen.isFinallyMarkerRequired
|
||||
|
||||
Reference in New Issue
Block a user