K2: don't generate Java overridden synthetics for Kotlin get/sets
#KT-59038 Fixed
This commit is contained in:
committed by
Space Team
parent
9e39b7ef87
commit
d8a20f1975
@@ -0,0 +1,37 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_K1: JVM_IR
|
||||
// ISSUE: KT-59038
|
||||
|
||||
// FILE: C.java
|
||||
abstract class C extends B {
|
||||
protected C(A a) {
|
||||
super(a);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
private class D(a: A) : C(a)
|
||||
|
||||
open class A
|
||||
|
||||
class E : A()
|
||||
|
||||
open class B(private val a: A) {
|
||||
open fun <T : A> getA(): T {
|
||||
return a as T
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val da = D(a)
|
||||
val aa = da.getA<A>()
|
||||
if (a !== aa) return "FAIL 1"
|
||||
|
||||
val e = E()
|
||||
val de = D(e)
|
||||
val ee = de.getA<E>()
|
||||
if (e !== ee) return "FAIL 2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
FILE fqName:<root> fileName:/test.kt
|
||||
CLASS CLASS name:D modality:FINAL visibility:private superTypes:[<root>.C]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
|
||||
CONSTRUCTOR visibility:public <> (a:<root>.A) returnType:<root>.D [primary]
|
||||
VALUE_PARAMETER name:a index:0 type:<root>.A
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'protected/*protected and package*/ constructor <init> (a: @[FlexibleNullability] <root>.A?) declared in <root>.C'
|
||||
a: GET_VAR 'a: <root>.A declared in <root>.D.<init>' type=<root>.A origin=null
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:private superTypes:[<root>.C]'
|
||||
FUN FAKE_OVERRIDE name:getA visibility:public modality:OPEN <T> ($this:<root>.B) returnType:T of <root>.D.getA [fake_override]
|
||||
overridden:
|
||||
public open fun getA <T> (): T of <root>.C.getA declared in <root>.C
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[<root>.A] reified:false
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
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 declared in <root>.C
|
||||
$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 <root>.C
|
||||
$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 <root>.C
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
$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> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]'
|
||||
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 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:B modality:OPEN visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
|
||||
CONSTRUCTOR visibility:public <> (a:<root>.A) returnType:<root>.B [primary]
|
||||
VALUE_PARAMETER name:a index:0 type:<root>.A
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public superTypes:[kotlin.Any]'
|
||||
PROPERTY name:a visibility:private modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:<root>.A visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'a: <root>.A declared in <root>.B.<init>' type=<root>.A origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:private modality:FINAL <> ($this:<root>.B) returnType:<root>.A
|
||||
correspondingProperty: PROPERTY name:a visibility:private modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='private final fun <get-a> (): <root>.A declared in <root>.B'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:<root>.A visibility:private [final]' type=<root>.A origin=null
|
||||
receiver: GET_VAR '<this>: <root>.B declared in <root>.B.<get-a>' type=<root>.B origin=null
|
||||
FUN name:getA visibility:public modality:OPEN <T> ($this:<root>.B) returnType:T of <root>.B.getA
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[<root>.A] reified:false
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun getA <T> (): T of <root>.B.getA declared in <root>.B'
|
||||
TYPE_OP type=T of <root>.B.getA origin=CAST typeOperand=T of <root>.B.getA
|
||||
CALL 'private final fun <get-a> (): <root>.A declared in <root>.B' type=<root>.A origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.B declared in <root>.B.getA' type=<root>.B 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 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,22 @@
|
||||
// FIR_IDENTICAL
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_K1: JVM_IR
|
||||
// ISSUE: KT-59038
|
||||
|
||||
// FILE: C.java
|
||||
abstract class C extends B {
|
||||
protected C(A a) {
|
||||
super(a);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
private class D(a: A) : C(a)
|
||||
|
||||
open class A
|
||||
|
||||
open class B(private val a: A) {
|
||||
open fun <T : A> getA(): T {
|
||||
return a as T
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
private class D : C {
|
||||
constructor(a: A) /* primary */ {
|
||||
super/*C*/(a = a)
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open class A {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open class B {
|
||||
constructor(a: A) /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
private val a: A
|
||||
field = a
|
||||
private get
|
||||
|
||||
open fun <T : A> getA(): T {
|
||||
return <this>.<get-a>() as T
|
||||
}
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// CHECK:
|
||||
// Mangled name: A
|
||||
// Public signature: /A|null[0]
|
||||
open class A {
|
||||
// CHECK:
|
||||
// Mangled name: A#<init>(){}
|
||||
// Public signature: /A.<init>|-5645683436151566731[0]
|
||||
constructor() /* primary */
|
||||
|
||||
}
|
||||
|
||||
// CHECK:
|
||||
// Mangled name: B
|
||||
// Public signature: /B|null[0]
|
||||
open class B {
|
||||
// CHECK:
|
||||
// Mangled name: B{}a
|
||||
// Public signature: /B.a|-1200697420457237799[0]
|
||||
private val a: A
|
||||
// CHECK JVM_IR:
|
||||
// Mangled name: B#<get-a>(){}A
|
||||
// Public signature: /B.a.<get-a>|736568356921033436[0]
|
||||
private get
|
||||
|
||||
// CHECK:
|
||||
// Mangled name: B#<init>(A){}
|
||||
// Public signature: /B.<init>|-3166999336802030902[0]
|
||||
constructor(a: A) /* primary */
|
||||
|
||||
// CHECK JVM_IR:
|
||||
// Mangled name: B#getA(){0§<A>}0:0
|
||||
// Public signature: /B.getA|6265629995120627543[0]
|
||||
open fun <T : A> getA(): T
|
||||
|
||||
}
|
||||
|
||||
// CHECK:
|
||||
// Mangled name: D
|
||||
// Public signature: [ File '<unknown>' <- /D|null[0] ]
|
||||
private class D : C {
|
||||
// CHECK:
|
||||
// Mangled name: D#<init>(A){}
|
||||
// Public signature: /D.<init>|-3166999336802030902[0]
|
||||
constructor(a: A) /* primary */
|
||||
|
||||
// CHECK:
|
||||
// Mangled name: D#getA(){0§<A>}0:0
|
||||
// Public signature: /D.getA|6265629995120627543[0]
|
||||
/* fake */ override fun <T : A> getA(): T
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user