JVM_IR KT-43066 Generate 'clone' in class implementing kotlin.Cloneable
This commit is contained in:
+5
@@ -66,6 +66,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
|||||||
runTest("compiler/testData/ir/irText/classes/classes.kt");
|
runTest("compiler/testData/ir/irText/classes/classes.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("cloneable.kt")
|
||||||
|
public void testCloneable() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/classes/cloneable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("companionObject.kt")
|
@TestMetadata("companionObject.kt")
|
||||||
public void testCompanionObject() throws Exception {
|
public void testCompanionObject() throws Exception {
|
||||||
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
|
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
|
||||||
|
|||||||
+21
-4
@@ -20,8 +20,10 @@ import org.jetbrains.kotlin.backend.jvm.ir.eraseTypeParameters
|
|||||||
import org.jetbrains.kotlin.backend.jvm.ir.isFromJava
|
import org.jetbrains.kotlin.backend.jvm.ir.isFromJava
|
||||||
import org.jetbrains.kotlin.backend.jvm.ir.isJvmAbstract
|
import org.jetbrains.kotlin.backend.jvm.ir.isJvmAbstract
|
||||||
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass
|
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass
|
||||||
|
import org.jetbrains.kotlin.builtins.StandardNames
|
||||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||||
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
@@ -407,16 +409,31 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
overriddenSymbols = irFunction.overriddenSymbols.toList()
|
overriddenSymbols = irFunction.overriddenSymbols.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getBridgeVisibility(bridge: Bridge): DescriptorVisibility {
|
||||||
|
// Even though kotlin.Cloneable#clone() is protected, corresponding bridge is 'public' in JVM.
|
||||||
|
if (bridge.overridden.name.asString() == "clone" &&
|
||||||
|
bridge.overridden.parentAsClass.hasEqualFqName(StandardNames.FqNames.cloneable.toSafe())
|
||||||
|
) {
|
||||||
|
return DescriptorVisibilities.PUBLIC
|
||||||
|
}
|
||||||
|
|
||||||
|
val overriddenVisibility = bridge.overridden.visibility
|
||||||
|
// Internal functions can be overridden by non-internal functions, which changes their names since the names of internal
|
||||||
|
// functions are mangled. In order to avoid mangling the name twice we reset the visibility for bridges to internal
|
||||||
|
// functions to public and use the mangled name directly.
|
||||||
|
return if (overriddenVisibility == DescriptorVisibilities.INTERNAL)
|
||||||
|
DescriptorVisibilities.PUBLIC
|
||||||
|
else
|
||||||
|
overriddenVisibility
|
||||||
|
}
|
||||||
|
|
||||||
private fun IrClass.addBridge(bridge: Bridge, target: IrSimpleFunction): IrSimpleFunction =
|
private fun IrClass.addBridge(bridge: Bridge, target: IrSimpleFunction): IrSimpleFunction =
|
||||||
addFunction {
|
addFunction {
|
||||||
startOffset = this@addBridge.startOffset
|
startOffset = this@addBridge.startOffset
|
||||||
endOffset = this@addBridge.startOffset
|
endOffset = this@addBridge.startOffset
|
||||||
modality = Modality.OPEN
|
modality = Modality.OPEN
|
||||||
origin = IrDeclarationOrigin.BRIDGE
|
origin = IrDeclarationOrigin.BRIDGE
|
||||||
// Internal functions can be overridden by non-internal functions, which changes their names since the names of internal
|
visibility = getBridgeVisibility(bridge)
|
||||||
// functions are mangled. In order to avoid mangling the name twice we reset the visibility for bridges to internal
|
|
||||||
// functions to public and use the mangled name directly.
|
|
||||||
visibility = bridge.overridden.visibility.takeUnless { it == DescriptorVisibilities.INTERNAL } ?: DescriptorVisibilities.PUBLIC
|
|
||||||
name = Name.identifier(bridge.signature.name)
|
name = Name.identifier(bridge.signature.name)
|
||||||
returnType = bridge.overridden.returnType.eraseTypeParameters()
|
returnType = bridge.overridden.returnType.eraseTypeParameters()
|
||||||
isSuspend = bridge.overridden.isSuspend
|
isSuspend = bridge.overridden.isSuspend
|
||||||
|
|||||||
+39
-9
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.backend.jvm.lower
|
|||||||
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||||
|
import org.jetbrains.kotlin.backend.common.ir.allOverridden
|
||||||
import org.jetbrains.kotlin.backend.common.ir.isMethodOfAny
|
import org.jetbrains.kotlin.backend.common.ir.isMethodOfAny
|
||||||
import org.jetbrains.kotlin.backend.common.ir.passTypeArgumentsFrom
|
import org.jetbrains.kotlin.backend.common.ir.passTypeArgumentsFrom
|
||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
@@ -16,19 +17,17 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
|||||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.backend.jvm.codegen.isJvmInterface
|
import org.jetbrains.kotlin.backend.jvm.codegen.isJvmInterface
|
||||||
import org.jetbrains.kotlin.backend.jvm.ir.*
|
import org.jetbrains.kotlin.backend.jvm.ir.*
|
||||||
|
import org.jetbrains.kotlin.builtins.StandardNames
|
||||||
import org.jetbrains.kotlin.config.JvmDefaultMode
|
import org.jetbrains.kotlin.config.JvmDefaultMode
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
|
||||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.deserialization.PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME
|
import org.jetbrains.kotlin.descriptors.deserialization.PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.builders.irBlockBody
|
import org.jetbrains.kotlin.ir.builders.irBlockBody
|
||||||
import org.jetbrains.kotlin.ir.builders.irCall
|
import org.jetbrains.kotlin.ir.builders.irCall
|
||||||
import org.jetbrains.kotlin.ir.builders.irGet
|
import org.jetbrains.kotlin.ir.builders.irGet
|
||||||
import org.jetbrains.kotlin.ir.builders.irReturn
|
import org.jetbrains.kotlin.ir.builders.irReturn
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrTypeOperator
|
import org.jetbrains.kotlin.ir.expressions.IrTypeOperator
|
||||||
@@ -46,14 +45,45 @@ internal val inheritedDefaultMethodsOnClassesPhase = makeIrFilePhase(
|
|||||||
private class InheritedDefaultMethodsOnClassesLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
private class InheritedDefaultMethodsOnClassesLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
||||||
override fun lower(irClass: IrClass) {
|
override fun lower(irClass: IrClass) {
|
||||||
if (!irClass.isJvmInterface) {
|
if (!irClass.isJvmInterface) {
|
||||||
irClass.declarations.transformInPlace { declaration ->
|
irClass.declarations.transformInPlace {
|
||||||
(declaration as? IrSimpleFunction)?.findInterfaceImplementation(context.state.jvmDefaultMode)?.let { implementation ->
|
transformMemberDeclaration(it)
|
||||||
generateDelegationToDefaultImpl(implementation, declaration)
|
|
||||||
} ?: declaration
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun transformMemberDeclaration(declaration: IrDeclaration): IrDeclaration {
|
||||||
|
if (declaration !is IrSimpleFunction) return declaration
|
||||||
|
|
||||||
|
if (declaration.isFakeOverride && declaration.name.asString() == "clone") {
|
||||||
|
val overriddenFunctions = declaration.allOverridden(false)
|
||||||
|
val cloneFun = overriddenFunctions.find { it.parentAsClass.hasEqualFqName(StandardNames.FqNames.cloneable.toSafe()) }
|
||||||
|
if (cloneFun != null && overriddenFunctions.all { it.isFakeOverride || it == cloneFun }) {
|
||||||
|
return generateCloneImplementation(declaration, cloneFun)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val implementation = declaration.findInterfaceImplementation(context.state.jvmDefaultMode)
|
||||||
|
?: return declaration
|
||||||
|
return generateDelegationToDefaultImpl(implementation, declaration)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateCloneImplementation(fakeOverride: IrSimpleFunction, cloneFun: IrSimpleFunction): IrSimpleFunction {
|
||||||
|
assert(fakeOverride.isFakeOverride)
|
||||||
|
val irFunction = context.cachedDeclarations.getDefaultImplsRedirection(fakeOverride)
|
||||||
|
val irClass = fakeOverride.parentAsClass
|
||||||
|
val classStartOffset = irClass.startOffset
|
||||||
|
context.createJvmIrBuilder(irFunction.symbol, classStartOffset, classStartOffset).apply {
|
||||||
|
irFunction.body = irBlockBody {
|
||||||
|
+irReturn(
|
||||||
|
irCall(cloneFun, origin = null, superQualifierSymbol = cloneFun.parentAsClass.symbol).apply {
|
||||||
|
dispatchReceiver = irGet(irFunction.dispatchReceiverParameter!!)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return irFunction
|
||||||
|
}
|
||||||
|
|
||||||
private fun generateDelegationToDefaultImpl(
|
private fun generateDelegationToDefaultImpl(
|
||||||
interfaceImplementation: IrSimpleFunction,
|
interfaceImplementation: IrSimpleFunction,
|
||||||
classOverride: IrSimpleFunction
|
classOverride: IrSimpleFunction
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
class A : Cloneable
|
||||||
|
|
||||||
|
interface I : Cloneable
|
||||||
|
|
||||||
|
interface I2 : Cloneable {
|
||||||
|
override fun clone(): Any
|
||||||
|
}
|
||||||
|
|
||||||
|
class C : I
|
||||||
|
|
||||||
|
class OC : I {
|
||||||
|
override fun clone(): OC = OC()
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ACC : Cloneable
|
||||||
|
|
||||||
|
abstract class ACI : I
|
||||||
|
|
||||||
|
abstract class ACI2 : I2
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class A {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method clone(): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public abstract class ACC {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method clone(): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public abstract class ACI {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method clone(): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public abstract class ACI2 {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class C {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method clone(): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class I$DefaultImpls {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public static @org.jetbrains.annotations.NotNull method clone(@org.jetbrains.annotations.NotNull p0: I): java.lang.Object
|
||||||
|
public final inner class I$DefaultImpls
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public interface I {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public final inner class I$DefaultImpls
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public interface I2 {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public abstract @org.jetbrains.annotations.NotNull method clone(): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class OC {
|
||||||
|
// source: 'cloneable.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method clone(): OC
|
||||||
|
public synthetic bridge method clone(): java.lang.Object
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
FILE fqName:<root> fileName:/cloneable.kt
|
||||||
|
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Cloneable]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Cloneable]'
|
||||||
|
FUN FAKE_OVERRIDE name:clone visibility:protected modality:OPEN <> ($this:kotlin.Cloneable) returnType:kotlin.Any [fake_override]
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Cloneable
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Cloneable]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I
|
||||||
|
FUN FAKE_OVERRIDE name:clone visibility:protected modality:OPEN <> ($this:kotlin.Cloneable) returnType:kotlin.Any [fake_override]
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Cloneable
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.I]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.I]'
|
||||||
|
FUN FAKE_OVERRIDE name:clone visibility:protected modality:OPEN <> ($this:kotlin.Cloneable) returnType:kotlin.Any [fake_override]
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Cloneable
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
CLASS CLASS name:OC modality:FINAL visibility:public superTypes:[<root>.I]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.OC
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:<root>.OC [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:OC modality:FINAL visibility:public superTypes:[<root>.I]'
|
||||||
|
FUN name:clone visibility:protected modality:FINAL <> ($this:<root>.OC) returnType:<root>.OC
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:<root>.OC
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='protected final fun clone (): <root>.OC declared in <root>.OC'
|
||||||
|
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.OC' type=<root>.OC origin=null
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class A : Cloneable
|
||||||
|
|
||||||
|
interface I : Cloneable
|
||||||
|
|
||||||
|
class C : I
|
||||||
|
|
||||||
|
class OC : I {
|
||||||
|
override fun clone(): OC = OC()
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
FILE fqName:<root> fileName:/cloneable.kt
|
||||||
|
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Cloneable]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Cloneable]'
|
||||||
|
FUN FAKE_OVERRIDE name:clone visibility:protected modality:OPEN <> ($this:kotlin.Cloneable) returnType:kotlin.Any [fake_override]
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Cloneable
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Cloneable]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I
|
||||||
|
FUN FAKE_OVERRIDE name:clone visibility:protected modality:OPEN <> ($this:kotlin.Cloneable) returnType:kotlin.Any [fake_override]
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Cloneable
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Cloneable
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.I]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.I]'
|
||||||
|
FUN FAKE_OVERRIDE name:clone visibility:protected modality:OPEN <> ($this:kotlin.Cloneable) returnType:kotlin.Any [fake_override]
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any [fake_override] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Cloneable
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String [fake_override] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
CLASS CLASS name:OC modality:FINAL visibility:public superTypes:[<root>.I]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.OC
|
||||||
|
CONSTRUCTOR visibility:public <> () returnType:<root>.OC [primary]
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:OC modality:FINAL visibility:public superTypes:[<root>.I]'
|
||||||
|
FUN name:clone visibility:protected modality:OPEN <> ($this:<root>.OC) returnType:<root>.OC
|
||||||
|
overridden:
|
||||||
|
protected open fun clone (): kotlin.Any [fake_override] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:<root>.OC
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='protected open fun clone (): <root>.OC declared in <root>.OC'
|
||||||
|
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.OC' type=<root>.OC origin=null
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String [fake_override] declared in <root>.I
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
+5
@@ -44,6 +44,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeListing/callableNameIntrinsic.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/callableNameIntrinsic.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("cloneable.kt")
|
||||||
|
public void testCloneable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/cloneable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("companionObjectVisibility_after.kt")
|
@TestMetadata("companionObjectVisibility_after.kt")
|
||||||
public void testCompanionObjectVisibility_after() throws Exception {
|
public void testCompanionObjectVisibility_after() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/companionObjectVisibility_after.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/companionObjectVisibility_after.kt");
|
||||||
|
|||||||
+5
@@ -44,6 +44,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
|||||||
runTest("compiler/testData/codegen/bytecodeListing/callableNameIntrinsic.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/callableNameIntrinsic.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("cloneable.kt")
|
||||||
|
public void testCloneable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/cloneable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("companionObjectVisibility_after.kt")
|
@TestMetadata("companionObjectVisibility_after.kt")
|
||||||
public void testCompanionObjectVisibility_after() throws Exception {
|
public void testCompanionObjectVisibility_after() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/companionObjectVisibility_after.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/companionObjectVisibility_after.kt");
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
|||||||
runTest("compiler/testData/ir/irText/classes/classes.kt");
|
runTest("compiler/testData/ir/irText/classes/classes.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("cloneable.kt")
|
||||||
|
public void testCloneable() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/classes/cloneable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("companionObject.kt")
|
@TestMetadata("companionObject.kt")
|
||||||
public void testCompanionObject() throws Exception {
|
public void testCompanionObject() throws Exception {
|
||||||
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
|
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user