From 4e1effd0655eac4a971d5f23e94652d08e544774 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 23 May 2019 18:19:29 +0200 Subject: [PATCH] Restore behavior in mapDefaultMethod for non-IR backend Although the intention of the change 9894c216c1 (#2341) was sensible, it unfortunately caused the type mapper to map a default method incorrectly under certain _undiscovered_ circumstances, which leads to incorrect bytecode being generated. Specifically, this led to an exception: java.lang.NoSuchMethodError : org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches$Companion.compileCodeFragmentCacheAware$default(Lorg/jetbrains/kotlin/psi/KtCodeFragment;Lcom/intellij/debugger/SourcePosition;Lkotlin/jvm/functions/Function0;ZILjava/lang/Object;)Lkotlin/Pair; in a developer branch where this class was refactored and moved to another module. I was not able to determine the exact reason of this error, so I'm workarounding it by limiting this change to the IR backend only (where it's needed), and postponing the investigation of the failure above for now. --- .../src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.kt index dfcf75a899e..fd36f7c861f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.kt @@ -911,7 +911,7 @@ class KotlinTypeMapper @JvmOverloads constructor( val isConstructor = isConstructor(jvmSignature) val descriptor = getDefaultDescriptor( jvmSignature, - if (isStaticMethod(kind, functionDescriptor) || isStaticDeclaration(functionDescriptor) || isConstructor) + if (isStaticMethod(kind, functionDescriptor) || isConstructor || (isIrBackend && isStaticDeclaration(functionDescriptor))) null else ownerType.descriptor, functionDescriptor.unwrapFrontendVersion(), if (isIrBackend && isConstructor) {