Do not duplicate inherited bridge
This commit is contained in:
+6
@@ -26,6 +26,12 @@ internal class OverriddenFunctionDescriptor(val descriptor: FunctionDescriptor,
|
|||||||
get() = overriddenDescriptor.isOverridable
|
get() = overriddenDescriptor.isOverridable
|
||||||
|| DescriptorUtils.getAllOverriddenDeclarations(overriddenDescriptor).any { it.isOverridable }
|
|| DescriptorUtils.getAllOverriddenDeclarations(overriddenDescriptor).any { it.isOverridable }
|
||||||
|
|
||||||
|
val inheritsBridge: Boolean
|
||||||
|
get() {
|
||||||
|
return !descriptor.kind.isReal
|
||||||
|
&& OverridingUtil.overrides(descriptor.target, overriddenDescriptor)
|
||||||
|
&& descriptor.bridgeDirectionsTo(overriddenDescriptor).allNotNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "(descriptor=$descriptor, overriddenDescriptor=$overriddenDescriptor)"
|
return "(descriptor=$descriptor, overriddenDescriptor=$overriddenDescriptor)"
|
||||||
|
|||||||
+1
-3
@@ -170,9 +170,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
get() {
|
get() {
|
||||||
val target = descriptor.target
|
val target = descriptor.target
|
||||||
if (!needBridge) return target
|
if (!needBridge) return target
|
||||||
val bridgeOwner = if (!descriptor.kind.isReal
|
val bridgeOwner = if (inheritsBridge) {
|
||||||
&& OverridingUtil.overrides(target, overriddenDescriptor)
|
|
||||||
&& descriptor.bridgeDirectionsTo(overriddenDescriptor).allNotNeeded()) {
|
|
||||||
target // Bridge is inherited from superclass.
|
target // Bridge is inherited from superclass.
|
||||||
} else {
|
} else {
|
||||||
descriptor
|
descriptor
|
||||||
|
|||||||
+1
@@ -81,6 +81,7 @@ internal class BridgesBuilding(val context: Context) : ClassLoweringPass {
|
|||||||
.map { OverriddenFunctionDescriptor(function, it) }
|
.map { OverriddenFunctionDescriptor(function, it) }
|
||||||
.filter { !it.bridgeDirections.allNotNeeded() }
|
.filter { !it.bridgeDirections.allNotNeeded() }
|
||||||
.filter { it.canBeCalledVirtually }
|
.filter { it.canBeCalledVirtually }
|
||||||
|
.filter { !it.inheritsBridge }
|
||||||
.distinctBy { it.bridgeDirections }
|
.distinctBy { it.bridgeDirections }
|
||||||
.forEach {
|
.forEach {
|
||||||
buildBridge(it, irClass)
|
buildBridge(it, irClass)
|
||||||
|
|||||||
Reference in New Issue
Block a user