From bb537aa8342cf5972f6e2f3e6a72b53b78787939 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 30 Jun 2016 20:10:59 +0300 Subject: [PATCH] Simplify method contract and add assertion We don't generate stubs for final built-ins anyway (as well as special bridges) --- .../kotlin/codegen/builtinSpecialBridges.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt index 2501835bc86..fbb0daad1d5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt @@ -89,8 +89,8 @@ object BuiltinSpecialBridgesUtil { val bridges: MutableSet> = mutableSetOf() val superImplementationDescriptor = - if (specialBridge != null) - findSuperImplementationForStubDelegation(function, fake, isBodyOwner, signatureByDescriptor) + if (specialBridge != null && fake && !functionHandle.isAbstract) + findSuperImplementationForStubDelegation(function, isBodyOwner, signatureByDescriptor) else null @@ -140,17 +140,21 @@ object BuiltinSpecialBridgesUtil { */ private fun findSuperImplementationForStubDelegation( function: FunctionDescriptor, - fake: Boolean, isBodyOwner: (DeclarationDescriptor) -> Boolean, signatureByDescriptor: (FunctionDescriptor) -> Signature ): FunctionDescriptor? { - if (function.modality != Modality.OPEN || !fake) return null val implementation = findConcreteSuperDeclaration(DescriptorBasedFunctionHandle(function, isBodyOwner)).descriptor + + // Implementation from interface will be generated by common mechanism if (DescriptorUtils.isInterface(implementation.containingDeclaration)) return null // Implementation in super-class already has proper signature if (signatureByDescriptor(function) == signatureByDescriptor(implementation)) return null + assert(function.modality == Modality.OPEN) { + "Should generate stubs only for non-abstract built-ins, but ${function.name} is ${function.modality}" + } + return implementation }