Simplify method contract and add assertion
We don't generate stubs for final built-ins anyway (as well as special bridges)
This commit is contained in:
@@ -89,8 +89,8 @@ object BuiltinSpecialBridgesUtil {
|
||||
val bridges: MutableSet<BridgeForBuiltinSpecial<Signature>> = 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 <Signature> 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user