FIR2IR: don't add SAM conversion for explicit subtype cases
This commit is contained in:
committed by
TeamCityServer
parent
7df289746c
commit
d753d21dee
+13
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.fir.resolve.FirSamResolverImpl
|
|||||||
import org.jetbrains.kotlin.fir.resolve.calls.getExpectedTypeForSAMConversion
|
import org.jetbrains.kotlin.fir.resolve.calls.getExpectedTypeForSAMConversion
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.isFunctional
|
import org.jetbrains.kotlin.fir.resolve.calls.isFunctional
|
||||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType
|
import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.isKMutableProperty
|
import org.jetbrains.kotlin.fir.resolve.inference.isKMutableProperty
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
@@ -38,6 +39,7 @@ import org.jetbrains.kotlin.ir.types.*
|
|||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.hasNoSideEffects
|
import org.jetbrains.kotlin.psi2ir.generators.hasNoSideEffects
|
||||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||||
|
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||||
|
|
||||||
class CallAndReferenceGenerator(
|
class CallAndReferenceGenerator(
|
||||||
private val components: Fir2IrComponents,
|
private val components: Fir2IrComponents,
|
||||||
@@ -615,6 +617,17 @@ class CallAndReferenceGenerator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun needSamConversion(argument: FirExpression, parameter: FirValueParameter): Boolean {
|
private fun needSamConversion(argument: FirExpression, parameter: FirValueParameter): Boolean {
|
||||||
|
// If the type of the argument is already an explicitly subtype of the type of the parameter, we don't need SAM conversion.
|
||||||
|
if (argument.typeRef !is FirResolvedTypeRef ||
|
||||||
|
AbstractTypeChecker.isSubtypeOf(
|
||||||
|
session.inferenceComponents.ctx,
|
||||||
|
argument.typeRef.coneType,
|
||||||
|
parameter.returnTypeRef.coneType,
|
||||||
|
isFromNullabilityConstraint = true
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
// If the expected type is a built-in functional type, we don't need SAM conversion.
|
// If the expected type is a built-in functional type, we don't need SAM conversion.
|
||||||
val expectedType = argument.getExpectedTypeForSAMConversion(parameter)
|
val expectedType = argument.getExpectedTypeForSAMConversion(parameter)
|
||||||
if (expectedType is ConeTypeParameterType || expectedType.isBuiltinFunctionalType(session)) {
|
if (expectedType is ConeTypeParameterType || expectedType.isBuiltinFunctionalType(session)) {
|
||||||
|
|||||||
Vendored
+2
-2
@@ -64,7 +64,7 @@ fun test4(fn: Function1<Int, Unit>) {
|
|||||||
fn is IFoo -> { // BLOCK
|
fn is IFoo -> { // BLOCK
|
||||||
val <<array>>: A = A
|
val <<array>>: A = A
|
||||||
val <<index_0>>: IFoo = fn /*as IFoo */
|
val <<index_0>>: IFoo = fn /*as IFoo */
|
||||||
<<array>>.set(i = <<index_0>> /*-> IFoo */, newValue = <<array>>.get(i = <<index_0>> /*-> IFoo */).plus(other = 1))
|
<<array>>.set(i = <<index_0>>, newValue = <<array>>.get(i = <<index_0>>).plus(other = 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ fun test6(a: Any) {
|
|||||||
{ // BLOCK
|
{ // BLOCK
|
||||||
val <<array>>: A = A
|
val <<array>>: A = A
|
||||||
val <<index_0>>: Function1<Int, Unit> = a /*as Function1<Int, Unit> */
|
val <<index_0>>: Function1<Int, Unit> = a /*as Function1<Int, Unit> */
|
||||||
<<array>>.set(i = <<index_0>> /*-> IFoo */, newValue = <<array>>.get(i = <<index_0>> /*-> IFoo */).plus(other = 1))
|
<<array>>.set(i = <<index_0>>, newValue = <<array>>.get(i = <<index_0>>).plus(other = 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -141,13 +141,11 @@ FILE fqName:<root> fileName:/caoWithAdaptationForSam.kt
|
|||||||
GET_VAR 'fn: kotlin.Function1<kotlin.Int, kotlin.Unit> declared in <root>.test4' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null
|
GET_VAR 'fn: kotlin.Function1<kotlin.Int, kotlin.Unit> declared in <root>.test4' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null
|
||||||
CALL 'public final fun set (i: <root>.IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in <root>' type=kotlin.Unit origin=null
|
CALL 'public final fun set (i: <root>.IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in <root>' type=kotlin.Unit origin=null
|
||||||
$receiver: GET_VAR 'val tmp_2: <root>.A [val] declared in <root>.test4' type=<root>.A origin=null
|
$receiver: GET_VAR 'val tmp_2: <root>.A [val] declared in <root>.test4' type=<root>.A origin=null
|
||||||
i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
|
i: GET_VAR 'val tmp_3: <root>.IFoo [val] declared in <root>.test4' type=<root>.IFoo origin=null
|
||||||
GET_VAR 'val tmp_3: <root>.IFoo [val] declared in <root>.test4' type=<root>.IFoo origin=null
|
|
||||||
newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||||
$this: CALL 'public final fun get (i: <root>.IFoo): kotlin.Int [operator] declared in <root>' type=kotlin.Int origin=null
|
$this: CALL 'public final fun get (i: <root>.IFoo): kotlin.Int [operator] declared in <root>' type=kotlin.Int origin=null
|
||||||
$receiver: GET_VAR 'val tmp_2: <root>.A [val] declared in <root>.test4' type=<root>.A origin=null
|
$receiver: GET_VAR 'val tmp_2: <root>.A [val] declared in <root>.test4' type=<root>.A origin=null
|
||||||
i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
|
i: GET_VAR 'val tmp_3: <root>.IFoo [val] declared in <root>.test4' type=<root>.IFoo origin=null
|
||||||
GET_VAR 'val tmp_3: <root>.IFoo [val] declared in <root>.test4' type=<root>.IFoo origin=null
|
|
||||||
other: CONST Int type=kotlin.Int value=1
|
other: CONST Int type=kotlin.Int value=1
|
||||||
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||||
@@ -189,11 +187,9 @@ FILE fqName:<root> fileName:/caoWithAdaptationForSam.kt
|
|||||||
GET_VAR 'a: kotlin.Any declared in <root>.test6' type=kotlin.Any origin=null
|
GET_VAR 'a: kotlin.Any declared in <root>.test6' type=kotlin.Any origin=null
|
||||||
CALL 'public final fun set (i: <root>.IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in <root>' type=kotlin.Unit origin=null
|
CALL 'public final fun set (i: <root>.IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in <root>' type=kotlin.Unit origin=null
|
||||||
$receiver: GET_VAR 'val tmp_6: <root>.A [val] declared in <root>.test6' type=<root>.A origin=null
|
$receiver: GET_VAR 'val tmp_6: <root>.A [val] declared in <root>.test6' type=<root>.A origin=null
|
||||||
i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
|
i: GET_VAR 'val tmp_7: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test6' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null
|
||||||
GET_VAR 'val tmp_7: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test6' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null
|
|
||||||
newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||||
$this: CALL 'public final fun get (i: <root>.IFoo): kotlin.Int [operator] declared in <root>' type=kotlin.Int origin=null
|
$this: CALL 'public final fun get (i: <root>.IFoo): kotlin.Int [operator] declared in <root>' type=kotlin.Int origin=null
|
||||||
$receiver: GET_VAR 'val tmp_6: <root>.A [val] declared in <root>.test6' type=<root>.A origin=null
|
$receiver: GET_VAR 'val tmp_6: <root>.A [val] declared in <root>.test6' type=<root>.A origin=null
|
||||||
i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
|
i: GET_VAR 'val tmp_7: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test6' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null
|
||||||
GET_VAR 'val tmp_7: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test6' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null
|
|
||||||
other: CONST Int type=kotlin.Int value=1
|
other: CONST Int type=kotlin.Int value=1
|
||||||
|
|||||||
Vendored
+6
-6
@@ -14,29 +14,29 @@ fun run2(r1: KRunnable, r2: KRunnable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun <T> test0(a: T) where T : KRunnable, T : Function0<Unit> {
|
fun <T> test0(a: T) where T : KRunnable, T : Function0<Unit> {
|
||||||
run1(r = a /*-> KRunnable */)
|
run1(r = a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test1(a: Function0<Unit>) {
|
fun test1(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is KRunnable -> run1(r = a /*as KRunnable */ /*-> KRunnable */)
|
a is KRunnable -> run1(r = a /*as KRunnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a: KRunnable) {
|
fun test2(a: KRunnable) {
|
||||||
a as Function0<Unit> /*~> Unit */
|
a as Function0<Unit> /*~> Unit */
|
||||||
run1(r = a /*as Function0<Unit> */ /*-> KRunnable */)
|
run1(r = a /*as Function0<Unit> */)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test3(a: Function0<Unit>) {
|
fun test3(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is KRunnable -> run2(r1 = a /*as KRunnable */ /*-> KRunnable */, r2 = a /*as KRunnable */ /*-> KRunnable */)
|
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is KRunnable -> run2(r1 = a /*as KRunnable */ /*-> KRunnable */, r2 = b /*-> KRunnable */)
|
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ fun test5x(a: Any) {
|
|||||||
when {
|
when {
|
||||||
a is KRunnable -> { // BLOCK
|
a is KRunnable -> { // BLOCK
|
||||||
a /*as KRunnable */ as Function0<Unit> /*~> Unit */
|
a /*as KRunnable */ as Function0<Unit> /*~> Unit */
|
||||||
run1(r = a /*as KRunnable */ /*-> KRunnable */)
|
run1(r = a /*as KRunnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-20
@@ -34,8 +34,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
VALUE_PARAMETER name:a index:0 type:T of <root>.test0
|
VALUE_PARAMETER name:a index:0 type:T of <root>.test0
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
r: GET_VAR 'a: T of <root>.test0 declared in <root>.test0' type=T of <root>.test0 origin=null
|
||||||
GET_VAR 'a: T of <root>.test0 declared in <root>.test0' type=T of <root>.test0 origin=null
|
|
||||||
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -44,9 +43,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
then: CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
r: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||||
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
|
||||||
FUN name:test2 visibility:public modality:FINAL <> (a:<root>.KRunnable) returnType:kotlin.Unit
|
FUN name:test2 visibility:public modality:FINAL <> (a:<root>.KRunnable) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:<root>.KRunnable
|
VALUE_PARAMETER name:a index:0 type:<root>.KRunnable
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -54,9 +52,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
||||||
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
|
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
|
||||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
r: TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
||||||
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
|
||||||
GET_VAR 'a: <root>.KRunnable declared in <root>.test2' type=<root>.KRunnable origin=null
|
|
||||||
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -65,12 +62,10 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
then: CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
r1: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
r1: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||||
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
r2: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||||
r2: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
|
||||||
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
|
||||||
@@ -80,9 +75,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.KRunnable
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
then: CALL 'public final fun run2 (r1: <root>.KRunnable, r2: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
r1: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
r1: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||||
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
|
||||||
r2: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
r2: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||||
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
@@ -108,9 +102,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||||
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
CALL 'public final fun run1 (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
r: TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
||||||
TYPE_OP type=<root>.KRunnable origin=IMPLICIT_CAST typeOperand=<root>.KRunnable
|
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
|
||||||
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
|
|||||||
+5
-5
@@ -1,24 +1,24 @@
|
|||||||
fun test1(a: Function0<Unit>) {
|
fun test1(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> runStatic(r = a /*as Runnable */ /*-> Runnable? */)
|
a is Runnable -> runStatic(r = a /*as Runnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a: Function0<Unit>) {
|
fun test2(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> J().run1(r = a /*as Runnable */ /*-> Runnable? */)
|
a is Runnable -> J().run1(r = a /*as Runnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test3(a: Function0<Unit>) {
|
fun test3(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> J().run2(r1 = a /*as Runnable */ /*-> Runnable? */, r2 = a /*as Runnable */ /*-> Runnable? */)
|
a is Runnable -> J().run2(r1 = a /*as Runnable */, r2 = a /*as Runnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> J().run2(r1 = a /*as Runnable */ /*-> Runnable? */, r2 = b /*-> Runnable? */)
|
a is Runnable -> J().run2(r1 = a /*as Runnable */, r2 = b /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ fun test5x(a: Any) {
|
|||||||
when {
|
when {
|
||||||
a is Runnable -> { // BLOCK
|
a is Runnable -> { // BLOCK
|
||||||
a /*as Runnable */ as Function0<Unit> /*~> Unit */
|
a /*as Runnable */ as Function0<Unit> /*~> Unit */
|
||||||
J().run1(r = a /*as Runnable */ /*-> Runnable? */)
|
J().run1(r = a /*as Runnable */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-18
@@ -7,9 +7,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
|
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun runStatic (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun runStatic (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
|
||||||
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -19,9 +18,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
|
||||||
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -31,12 +29,10 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r1: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
r2: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
|
||||||
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
|
||||||
@@ -47,9 +43,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r1: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
|
||||||
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
@@ -77,9 +72,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||||
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
|
||||||
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
|
|||||||
Reference in New Issue
Block a user