Added bridge for functions overriding return type with Unit
This commit is contained in:
+10
-11
@@ -212,7 +212,7 @@ fun ClassDescriptor.isAbstract() = this.modality == Modality.SEALED || this.moda
|
|||||||
|
|
||||||
internal fun FunctionDescriptor.hasValueTypeAt(index: Int): Boolean {
|
internal fun FunctionDescriptor.hasValueTypeAt(index: Int): Boolean {
|
||||||
when (index) {
|
when (index) {
|
||||||
0 -> return !isSuspend && returnType.let { it != null && it.isValueType() }
|
0 -> return !isSuspend && returnType.let { it != null && (it.isValueType() || it.isUnit()) }
|
||||||
1 -> return extensionReceiverParameter.let { it != null && it.type.isValueType() }
|
1 -> return extensionReceiverParameter.let { it != null && it.type.isValueType() }
|
||||||
else -> return this.valueParameters[index - 2].type.isValueType()
|
else -> return this.valueParameters[index - 2].type.isValueType()
|
||||||
}
|
}
|
||||||
@@ -220,7 +220,7 @@ internal fun FunctionDescriptor.hasValueTypeAt(index: Int): Boolean {
|
|||||||
|
|
||||||
internal fun FunctionDescriptor.hasReferenceAt(index: Int): Boolean {
|
internal fun FunctionDescriptor.hasReferenceAt(index: Int): Boolean {
|
||||||
when (index) {
|
when (index) {
|
||||||
0 -> return isSuspend || returnType.let { it != null && !it.isValueType() }
|
0 -> return isSuspend || returnType.let { it != null && !it.isValueType() && !it.isUnit() }
|
||||||
1 -> return extensionReceiverParameter.let { it != null && !it.type.isValueType() }
|
1 -> return extensionReceiverParameter.let { it != null && !it.type.isValueType() }
|
||||||
else -> return !this.valueParameters[index - 2].type.isValueType()
|
else -> return !this.valueParameters[index - 2].type.isValueType()
|
||||||
}
|
}
|
||||||
@@ -241,13 +241,12 @@ internal enum class BridgeDirection {
|
|||||||
TO_VALUE_TYPE
|
TO_VALUE_TYPE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FunctionDescriptor.bridgeDirectionToAt(target: FunctionDescriptor, index: Int): BridgeDirection {
|
private fun FunctionDescriptor.bridgeDirectionToAt(target: FunctionDescriptor, index: Int)
|
||||||
when {
|
= when {
|
||||||
hasValueTypeAt(index) && target.hasReferenceAt(index) -> return BridgeDirection.FROM_VALUE_TYPE
|
hasValueTypeAt(index) && target.hasReferenceAt(index) -> BridgeDirection.FROM_VALUE_TYPE
|
||||||
hasReferenceAt(index) && target.hasValueTypeAt(index) -> return BridgeDirection.TO_VALUE_TYPE
|
hasReferenceAt(index) && target.hasValueTypeAt(index) -> BridgeDirection.TO_VALUE_TYPE
|
||||||
else -> return BridgeDirection.NOT_NEEDED
|
else -> BridgeDirection.NOT_NEEDED
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal class BridgeDirections(val array: Array<BridgeDirection>) {
|
internal class BridgeDirections(val array: Array<BridgeDirection>) {
|
||||||
constructor(parametersCount: Int): this(Array<BridgeDirection>(parametersCount + 2, { BridgeDirection.NOT_NEEDED }))
|
constructor(parametersCount: Int): this(Array<BridgeDirection>(parametersCount + 2, { BridgeDirection.NOT_NEEDED }))
|
||||||
@@ -259,8 +258,8 @@ internal class BridgeDirections(val array: Array<BridgeDirection>) {
|
|||||||
array.forEach {
|
array.forEach {
|
||||||
result.append(when (it) {
|
result.append(when (it) {
|
||||||
BridgeDirection.FROM_VALUE_TYPE -> 'U' // unbox
|
BridgeDirection.FROM_VALUE_TYPE -> 'U' // unbox
|
||||||
BridgeDirection.TO_VALUE_TYPE -> 'B' // box
|
BridgeDirection.TO_VALUE_TYPE -> 'B' // box
|
||||||
BridgeDirection.NOT_NEEDED -> 'N' // none
|
BridgeDirection.NOT_NEEDED -> 'N' // none
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return result.toString()
|
return result.toString()
|
||||||
|
|||||||
Reference in New Issue
Block a user