[FIR2IR] Properly insert implicit casts to extension receiver in case of intersection smartcast type

^KT-62863 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-11-02 12:27:30 +02:00
committed by Space Team
parent 50106c740c
commit 420fbad73d
25 changed files with 548 additions and 91 deletions
@@ -6,13 +6,15 @@
package org.jetbrains.kotlin.fir.backend package org.jetbrains.kotlin.fir.backend
import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
import org.jetbrains.kotlin.fir.references.FirReference
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
import org.jetbrains.kotlin.ir.IrBuiltIns import org.jetbrains.kotlin.ir.IrBuiltIns
@@ -279,28 +281,64 @@ class Fir2IrImplicitCastInserter(
} }
} }
internal fun implicitCastFromDispatchReceiver( internal fun implicitCastFromReceivers(
original: IrExpression, originalIrReceiver: IrExpression,
coneKotlinType: ConeKotlinType, receiver: FirExpression,
calleeReference: FirReference?, selector: FirQualifiedAccessExpression,
typeOrigin: ConversionTypeOrigin, typeOrigin: ConversionTypeOrigin,
): IrExpression { ): IrExpression {
val referencedDeclaration = calleeReference?.toResolvedCallableSymbol()?.unwrapCallRepresentative()?.fir return implicitCastFromReceiverForIntersectionTypeOrNull(
originalIrReceiver,
receiver,
selector,
typeOrigin
) ?: implicitCastOrExpression(originalIrReceiver, receiver.resolvedType)
}
val dispatchReceiverType = private fun implicitCastFromReceiverForIntersectionTypeOrNull(
referencedDeclaration?.dispatchReceiverType as? ConeClassLikeType originalIrReceiver: IrExpression,
?: return implicitCastOrExpression(original, coneKotlinType) receiver: FirExpression,
selector: FirQualifiedAccessExpression,
typeOrigin: ConversionTypeOrigin,
): IrExpression? {
val receiverExpressionType = receiver.resolvedType as? ConeIntersectionType ?: return null
val referencedDeclaration = selector.calleeReference.toResolvedCallableSymbol()?.unwrapCallRepresentative()?.fir
val starProjectedDispatchReceiver = dispatchReceiverType.replaceArgumentsWithStarProjections() val receiverType = with(selector) {
when {
val castType = coneKotlinType as? ConeIntersectionType receiver === dispatchReceiver -> {
castType?.intersectedTypes?.forEach { componentType -> val dispatchReceiverType = referencedDeclaration?.dispatchReceiverType as? ConeClassLikeType ?: return null
if (AbstractTypeChecker.isSubtypeOf(session.typeContext, componentType, starProjectedDispatchReceiver)) { dispatchReceiverType.replaceArgumentsWithStarProjections()
return implicitCastOrExpression(original, componentType, typeOrigin) }
receiver === extensionReceiver -> {
val extensionReceiverType = referencedDeclaration?.receiverParameter?.typeRef?.coneType ?: return null
val substitutor = createSubstitutorFromTypeArguments(selector, referencedDeclaration)
substitutor.substituteOrSelf(extensionReceiverType)
}
else -> return null
} }
} }
return implicitCastOrExpression(original, coneKotlinType, typeOrigin) for (componentType in receiverExpressionType.intersectedTypes) {
if (AbstractTypeChecker.isSubtypeOf(session.typeContext, componentType, receiverType)) {
return implicitCastOrExpression(originalIrReceiver, componentType, typeOrigin)
}
}
return null
}
private fun createSubstitutorFromTypeArguments(
qualifiedAccessExpression: FirQualifiedAccessExpression,
callableDeclaration: FirCallableDeclaration,
): ConeSubstitutor {
if (qualifiedAccessExpression.typeArguments.isEmpty() || callableDeclaration.typeParameters.isEmpty()) return ConeSubstitutor.Empty
val map = buildMap {
for ((parameter, argument) in callableDeclaration.typeParameters.zip(qualifiedAccessExpression.typeArguments)) {
val argumentType = argument.toConeTypeProjection().type ?: continue
put(parameter.symbol, argumentType)
}
}
return ConeSubstitutorByMap(map, session)
} }
private fun implicitCastOrExpression( private fun implicitCastOrExpression(
@@ -309,12 +347,6 @@ class Fir2IrImplicitCastInserter(
return implicitCastOrExpression(original, castType.toIrType(typeOrigin)) return implicitCastOrExpression(original, castType.toIrType(typeOrigin))
} }
private fun implicitCastOrExpression(
original: IrExpression, castType: FirTypeRef, typeOrigin: ConversionTypeOrigin = ConversionTypeOrigin.DEFAULT
): IrExpression {
return implicitCastOrExpression(original, castType.toIrType(typeOrigin))
}
companion object { companion object {
internal fun implicitCastOrExpression(original: IrExpression, castType: IrType): IrExpression { internal fun implicitCastOrExpression(original: IrExpression, castType: IrType): IrExpression {
val originalNotNull = original.type.makeNotNull() val originalNotNull = original.type.makeNotNull()
@@ -573,7 +573,10 @@ class Fir2IrVisitor(
functionCall: FirFunctionCall, functionCall: FirFunctionCall,
dynamicOperator: IrDynamicOperator? dynamicOperator: IrDynamicOperator?
): IrExpression { ): IrExpression {
val explicitReceiverExpression = convertToIrReceiverExpression(functionCall.explicitReceiver, functionCall.calleeReference) val explicitReceiverExpression = convertToIrReceiverExpression(
functionCall.explicitReceiver,
functionCall
)
return callGenerator.convertToIrCall( return callGenerator.convertToIrCall(
functionCall, functionCall,
functionCall.resolvedType, functionCall.resolvedType,
@@ -653,7 +656,7 @@ class Fir2IrVisitor(
qualifiedAccessExpression: FirQualifiedAccessExpression, qualifiedAccessExpression: FirQualifiedAccessExpression,
): IrExpression = whileAnalysing(session, qualifiedAccessExpression) { ): IrExpression = whileAnalysing(session, qualifiedAccessExpression) {
val explicitReceiverExpression = convertToIrReceiverExpression( val explicitReceiverExpression = convertToIrReceiverExpression(
qualifiedAccessExpression.explicitReceiver, qualifiedAccessExpression.calleeReference qualifiedAccessExpression.explicitReceiver, qualifiedAccessExpression
) )
return callGenerator.convertToIrCall( return callGenerator.convertToIrCall(
qualifiedAccessExpression, qualifiedAccessExpression.resolvedType, explicitReceiverExpression qualifiedAccessExpression, qualifiedAccessExpression.resolvedType, explicitReceiverExpression
@@ -849,7 +852,7 @@ class Fir2IrVisitor(
private fun convertCallableReferenceAccess(callableReferenceAccess: FirCallableReferenceAccess, isDelegate: Boolean): IrElement { private fun convertCallableReferenceAccess(callableReferenceAccess: FirCallableReferenceAccess, isDelegate: Boolean): IrElement {
val explicitReceiverExpression = convertToIrReceiverExpression( val explicitReceiverExpression = convertToIrReceiverExpression(
callableReferenceAccess.explicitReceiver, callableReferenceAccess.calleeReference, callableReferenceAccess callableReferenceAccess.explicitReceiver, callableReferenceAccess
) )
return callGenerator.convertToIrCallableReference( return callGenerator.convertToIrCallableReference(
callableReferenceAccess, callableReferenceAccess,
@@ -862,9 +865,11 @@ class Fir2IrVisitor(
variableAssignment: FirVariableAssignment, variableAssignment: FirVariableAssignment,
data: Any? data: Any?
): IrElement = whileAnalysing(session, variableAssignment) { ): IrElement = whileAnalysing(session, variableAssignment) {
val explicitReceiverExpression = convertToIrReceiverExpression( val explicitReceiverExpression = variableAssignment.explicitReceiver?.let { receiverExpression ->
variableAssignment.explicitReceiver, variableAssignment.calleeReference convertToIrReceiverExpression(
) receiverExpression, variableAssignment.unwrapLValue()!!
)
}
return callGenerator.convertToIrSetCall(variableAssignment, explicitReceiverExpression) return callGenerator.convertToIrSetCall(variableAssignment, explicitReceiverExpression)
} }
@@ -923,31 +928,31 @@ class Fir2IrVisitor(
} }
internal fun convertToIrReceiverExpression( internal fun convertToIrReceiverExpression(
expression: FirExpression?, receiver: FirExpression?,
calleeReference: FirReference?, selector: FirQualifiedAccessExpression,
callableReferenceAccess: FirCallableReferenceAccess? = null
): IrExpression? { ): IrExpression? {
return when (expression) { val selectorCalleeReference = selector.calleeReference
return when (receiver) {
null -> return null null -> return null
is FirResolvedQualifier -> callGenerator.convertToGetObject(expression, callableReferenceAccess) is FirResolvedQualifier -> callGenerator.convertToGetObject(receiver, selector as? FirCallableReferenceAccess)
is FirFunctionCall, is FirThisReceiverExpression, is FirCallableReferenceAccess, is FirSmartCastExpression -> is FirFunctionCall, is FirThisReceiverExpression, is FirCallableReferenceAccess, is FirSmartCastExpression ->
convertToIrExpression(expression) convertToIrExpression(receiver)
else -> if (expression is FirQualifiedAccessExpression && expression.explicitReceiver == null) { else -> if (receiver is FirQualifiedAccessExpression && receiver.explicitReceiver == null) {
val variableAsFunctionMode = calleeReference is FirResolvedNamedReference && val variableAsFunctionMode = selectorCalleeReference is FirResolvedNamedReference &&
calleeReference.name != OperatorNameConventions.INVOKE && selectorCalleeReference.name != OperatorNameConventions.INVOKE &&
(calleeReference.resolvedSymbol as? FirCallableSymbol)?.callableId?.callableName == OperatorNameConventions.INVOKE (selectorCalleeReference.resolvedSymbol as? FirCallableSymbol)?.callableId?.callableName == OperatorNameConventions.INVOKE
callGenerator.convertToIrCall( callGenerator.convertToIrCall(
expression, expression.resolvedType, explicitReceiverExpression = null, receiver, receiver.resolvedType, explicitReceiverExpression = null,
variableAsFunctionMode = variableAsFunctionMode variableAsFunctionMode = variableAsFunctionMode
) )
} else { } else {
convertToIrExpression(expression) convertToIrExpression(receiver)
} }
}?.run { }?.run {
if (expression is FirQualifiedAccessExpression && expression.calleeReference is FirSuperReference) return@run this if (receiver is FirQualifiedAccessExpression && receiver.calleeReference is FirSuperReference) return@run this
implicitCastInserter.implicitCastFromDispatchReceiver( implicitCastInserter.implicitCastFromReceivers(
this, expression.resolvedType, calleeReference, this, receiver, selector,
conversionScope.defaultConversionTypeOrigin() conversionScope.defaultConversionTypeOrigin()
) )
} }
@@ -1056,7 +1061,7 @@ class Fir2IrVisitor(
val originalVararg = arrayAccess.resolvedArgumentMapping?.keys?.filterIsInstance<FirVarargArgumentsExpression>()?.firstOrNull() val originalVararg = arrayAccess.resolvedArgumentMapping?.keys?.filterIsInstance<FirVarargArgumentsExpression>()?.firstOrNull()
(callGenerator.convertToIrCall( (callGenerator.convertToIrCall(
arrayAccess, arrayAccess.resolvedType, arrayAccess, arrayAccess.resolvedType,
convertToIrReceiverExpression(receiverValue, arrayAccess.calleeReference), convertToIrReceiverExpression(receiverValue, arrayAccess),
noArguments = true noArguments = true
) as IrDynamicOperatorExpression).apply { ) as IrDynamicOperatorExpression).apply {
originalVararg?.arguments?.forEach { originalVararg?.arguments?.forEach {
@@ -1075,7 +1080,7 @@ class Fir2IrVisitor(
callGenerator.convertToIrCall( callGenerator.convertToIrCall(
qualifiedAccess, qualifiedAccess,
qualifiedAccess.resolvedType, qualifiedAccess.resolvedType,
convertToIrReceiverExpression(receiverExpression, qualifiedAccess.calleeReference), convertToIrReceiverExpression(receiverExpression, qualifiedAccess),
) )
} }
return callGenerator.convertToIrCall( return callGenerator.convertToIrCall(
@@ -1249,7 +1249,7 @@ class CallAndReferenceGenerator(
} }
return firReceiver return firReceiver
?.let { visitor.convertToIrReceiverExpression(it, calleeReference, this as? FirCallableReferenceAccess) } ?.let { visitor.convertToIrReceiverExpression(it, this) }
?: explicitReceiverExpression ?: explicitReceiverExpression
} }
@@ -1576,6 +1576,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1642,6 +1648,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("javaSyntheticGenericPropretyAccess.kt") @TestMetadata("javaSyntheticGenericPropretyAccess.kt")
public void testJavaSyntheticGenericPropretyAccess() throws Exception { public void testJavaSyntheticGenericPropretyAccess() throws Exception {
@@ -1576,6 +1576,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1642,6 +1648,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("javaSyntheticGenericPropretyAccess.kt") @TestMetadata("javaSyntheticGenericPropretyAccess.kt")
public void testJavaSyntheticGenericPropretyAccess() throws Exception { public void testJavaSyntheticGenericPropretyAccess() throws Exception {
@@ -0,0 +1,30 @@
FILE fqName:<root> fileName:/genericReceiverOnExtensionWithSmartcast.kt
FUN name:bar visibility:public modality:FINAL <F> ($receiver:F of <root>.bar) returnType:kotlin.Unit
TYPE_PARAMETER name:F index:0 variance: superTypes:[kotlin.CharSequence] reified:false
$receiver: VALUE_PARAMETER name:<this> type:F of <root>.bar
BLOCK_BODY
FUN name:test_1 visibility:public modality:FINAL <T> (x:kotlin.Any) returnType:kotlin.Unit [inline]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.CharSequence] reified:true
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of <root>.test_1
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun bar <F> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<F>: T of <root>.test_1
$receiver: TYPE_OP type=T of <root>.test_1 origin=IMPLICIT_CAST typeOperand=T of <root>.test_1
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
FUN name:test_2 visibility:public modality:FINAL <> (x:kotlin.Any?) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any?
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.CharSequence
GET_VAR 'x: kotlin.Any? declared in <root>.test_2' type=kotlin.Any? origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun bar <F> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<F>: kotlin.CharSequence
$receiver: TYPE_OP type=kotlin.CharSequence origin=IMPLICIT_CAST typeOperand=kotlin.CharSequence
GET_VAR 'x: kotlin.Any? declared in <root>.test_2' type=kotlin.Any? origin=null
@@ -0,0 +1,14 @@
// FIR_IDENTICAL
fun <F : CharSequence> F.bar() {}
inline fun <reified T : CharSequence> test_1(x: Any) {
if (x is T) {
x.bar()
}
}
fun test_2(x: Any?) {
if (x is CharSequence) {
x.bar()
}
}
@@ -0,0 +1,18 @@
fun <F : CharSequence> F.bar() {
}
inline fun <reified T : CharSequence> test_1(x: Any) {
when {
x is T -> { // BLOCK
x /*as T */.bar<T>()
}
}
}
fun test_2(x: Any?) {
when {
x is CharSequence -> { // BLOCK
x /*as CharSequence */.bar<CharSequence>()
}
}
}
@@ -0,0 +1,17 @@
// CHECK:
// Mangled name: #bar@0:0(){0§<kotlin.CharSequence>}
// Public signature: /bar|8964320427600610167[0]
// Public signature debug description: bar@0:0(){0§<kotlin.CharSequence>}
fun <F : CharSequence> F.bar(): Unit
// CHECK:
// Mangled name: #test_1(kotlin.Any){0§<kotlin.CharSequence>}
// Public signature: /test_1|-9076880516293570076[0]
// Public signature debug description: test_1(kotlin.Any){0§<kotlin.CharSequence>}
inline fun <reified T : CharSequence> test_1(x: Any): Unit
// CHECK:
// Mangled name: #test_2(kotlin.Any?){}
// Public signature: /test_2|-2820233899677445404[0]
// Public signature debug description: test_2(kotlin.Any?){}
fun test_2(x: Any?): Unit
@@ -0,0 +1,90 @@
FILE fqName:<root> fileName:/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt
CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Bar<T of <root>.Bar>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
CONSTRUCTOR visibility:public <> () returnType:<root>.Bar<T of <root>.Bar> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL 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
FUN name:specificExt visibility:public modality:FINAL <> ($receiver:<root>.Bar<kotlin.Int>) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:<root>.Bar<kotlin.Int>
BLOCK_BODY
FUN name:test_1_1 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_1' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_1' type=kotlin.Any origin=null
CALL 'public final fun specificExt (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_1' type=kotlin.Any origin=null
FUN name:test_1_2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_2' type=kotlin.Any origin=null
CALL 'public final fun specificExt (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_1_2' type=kotlin.Any origin=null
FUN name:parameterizedExt visibility:public modality:FINAL <T> ($receiver:<root>.Bar<T of <root>.parameterizedExt>) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
$receiver: VALUE_PARAMETER name:<this> type:<root>.Bar<T of <root>.parameterizedExt>
BLOCK_BODY
FUN name:test_2_1 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.String
$receiver: TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Int
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_1' type=kotlin.Any origin=null
FUN name:test_2_2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.Int> origin=CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Bar<kotlin.String> origin=CAST typeOperand=<root>.Bar<kotlin.String>
TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.String
$receiver: TYPE_OP type=<root>.Bar<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
CALL 'public final fun parameterizedExt <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Int
$receiver: TYPE_OP type=<root>.Bar<kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.test_2_2' type=kotlin.Any origin=null
@@ -0,0 +1,41 @@
// FIR_IDENTICAL
// IGNORE_BACKEND_K1: ANY
// Reason: K1 can't resolve calls in test_2_1 and test_2_2 functions
// SKIP_KLIB_TEST
// Reason: AbstractKlibIrTextTestCase doen't support IGNORE_BACKEND_K1 directive
// ISSUE: KT-62863
class Bar<T>
fun Bar<Int>.specificExt() {}
fun test_1_1(x: Any) {
x as Bar<String>
x as Bar<Int>
x.specificExt()
}
fun test_1_2(x: Any) {
x as Bar<Int>
x as Bar<String>
x.specificExt()
}
fun <T> Bar<T>.parameterizedExt() {}
fun test_2_1(x: Any) {
x as Bar<String>
x as Bar<Int>
x.parameterizedExt<String>()
x.parameterizedExt<Int>()
}
fun test_2_2(x: Any) {
x as Bar<Int>
x as Bar<String>
x.parameterizedExt<String>()
x.parameterizedExt<Int>()
}
@@ -0,0 +1,40 @@
class Bar<T : Any?> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
fun Bar<Int>.specificExt() {
}
fun test_1_1(x: Any) {
x as Bar<String> /*~> Unit */
x /*as Bar<String> */ as Bar<Int> /*~> Unit */
x /*as Bar<Int> */.specificExt()
}
fun test_1_2(x: Any) {
x as Bar<Int> /*~> Unit */
x /*as Bar<Int> */ as Bar<String> /*~> Unit */
x /*as Bar<Int> */.specificExt()
}
fun <T : Any?> Bar<T>.parameterizedExt() {
}
fun test_2_1(x: Any) {
x as Bar<String> /*~> Unit */
x /*as Bar<String> */ as Bar<Int> /*~> Unit */
x /*as Bar<String> */.parameterizedExt<String>()
x /*as Bar<Int> */.parameterizedExt<Int>()
}
fun test_2_2(x: Any) {
x as Bar<Int> /*~> Unit */
x /*as Bar<Int> */ as Bar<String> /*~> Unit */
x /*as Bar<String> */.parameterizedExt<String>()
x /*as Bar<Int> */.parameterizedExt<Int>()
}
@@ -0,0 +1,47 @@
// CHECK:
// Mangled name: Bar
// Public signature: /Bar|null[0]
class Bar<T : Any?> {
// CHECK:
// Mangled name: Bar#<init>(){}
// Public signature: /Bar.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK:
// Mangled name: #parameterizedExt@Bar<0:0>(){0§<kotlin.Any?>}
// Public signature: /parameterizedExt|238116600414962466[0]
// Public signature debug description: parameterizedExt@Bar<0:0>(){0§<kotlin.Any?>}
fun <T : Any?> Bar<T>.parameterizedExt(): Unit
// CHECK:
// Mangled name: #specificExt@Bar<kotlin.Int>(){}
// Public signature: /specificExt|-1310832403295072487[0]
// Public signature debug description: specificExt@Bar<kotlin.Int>(){}
fun Bar<Int>.specificExt(): Unit
// CHECK:
// Mangled name: #test_1_1(kotlin.Any){}
// Public signature: /test_1_1|7398425926544174899[0]
// Public signature debug description: test_1_1(kotlin.Any){}
fun test_1_1(x: Any): Unit
// CHECK:
// Mangled name: #test_1_2(kotlin.Any){}
// Public signature: /test_1_2|7281604678448694217[0]
// Public signature debug description: test_1_2(kotlin.Any){}
fun test_1_2(x: Any): Unit
// CHECK:
// Mangled name: #test_2_1(kotlin.Any){}
// Public signature: /test_2_1|605030431757647889[0]
// Public signature debug description: test_2_1(kotlin.Any){}
fun test_2_1(x: Any): Unit
// CHECK:
// Mangled name: #test_2_2(kotlin.Any){}
// Public signature: /test_2_2|-2792936422375173693[0]
// Public signature debug description: test_2_2(kotlin.Any){}
fun test_2_2(x: Any): Unit
@@ -72,10 +72,12 @@ FILE fqName:<root> fileName:/smartCastAside2.kt
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any <T>: kotlin.Any
$receiver: GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null $receiver: TYPE_OP type=<root>.Foo<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Foo<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any <T>: kotlin.Any
$receiver: GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null $receiver: TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
GET_VAR 'x: kotlin.Any declared in <root>.test_1' type=kotlin.Any origin=null
FUN name:test_2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit FUN name:test_2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY BLOCK_BODY
@@ -98,14 +100,16 @@ FILE fqName:<root> fileName:/smartCastAside2.kt
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any <T>: kotlin.Any
$receiver: CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL $receiver: TYPE_OP type=<root>.Foo<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Foo<kotlin.Any>
<T0>: kotlin.Any CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null <T0>: kotlin.Any
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any <T>: kotlin.Any
$receiver: CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL $receiver: TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
<T0>: kotlin.Any CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null <T0>: kotlin.Any
arg0: GET_VAR 'x: kotlin.Any declared in <root>.test_2' type=kotlin.Any origin=null
FUN name:test_3 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit FUN name:test_3 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any VALUE_PARAMETER name:x index:0 type:kotlin.Any
BLOCK_BODY BLOCK_BODY
@@ -148,31 +152,33 @@ FILE fqName:<root> fileName:/smartCastAside2.kt
then: GET_VAR 'val tmp_1: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null then: GET_VAR 'val tmp_1: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null CALL 'public final fun extFoo <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any <T>: kotlin.Any
$receiver: BLOCK type=kotlin.Any origin=ELVIS $receiver: TYPE_OP type=<root>.Foo<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Foo<kotlin.Any>
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Any [val] BLOCK type=kotlin.Any origin=ELVIS
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Any [val]
WHEN type=kotlin.Any origin=null GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
BRANCH WHEN type=kotlin.Any origin=null
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ BRANCH
arg0: GET_VAR 'val tmp_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg1: CONST Null type=kotlin.Nothing? value=null arg0: GET_VAR 'val tmp_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null arg1: CONST Null type=kotlin.Nothing? value=null
<K>: kotlin.Any then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null
BRANCH <K>: kotlin.Any
if: CONST Boolean type=kotlin.Boolean value=true BRANCH
then: GET_VAR 'val tmp_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_2: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null CALL 'public final fun extBar <T> (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any <T>: kotlin.Any
$receiver: BLOCK type=kotlin.Any origin=ELVIS $receiver: TYPE_OP type=<root>.Bar<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.Bar<kotlin.Any>
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Any [val] BLOCK type=kotlin.Any origin=ELVIS
GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Any [val]
WHEN type=kotlin.Any origin=null GET_VAR 'x: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
BRANCH WHEN type=kotlin.Any origin=null
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ BRANCH
arg0: GET_VAR 'val tmp_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg1: CONST Null type=kotlin.Nothing? value=null arg0: GET_VAR 'val tmp_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null arg1: CONST Null type=kotlin.Nothing? value=null
<K>: kotlin.Any then: CALL 'public final fun materialize <K> (): K of <root>.materialize declared in <root>' type=kotlin.Any origin=null
BRANCH <K>: kotlin.Any
if: CONST Boolean type=kotlin.Boolean value=true BRANCH
then: GET_VAR 'val tmp_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_3: kotlin.Any declared in <root>.test_3' type=kotlin.Any origin=null
@@ -29,8 +29,8 @@ fun test_1(x: Any) {
x /*as Bar<Any> */ as Foo<Any> /*~> Unit */ x /*as Bar<Any> */ as Foo<Any> /*~> Unit */
x /*as Foo<Any> */.foo() x /*as Foo<Any> */.foo()
x /*as Bar<Any> */.bar() x /*as Bar<Any> */.bar()
x.extFoo<Any>() x /*as Foo<Any> */.extFoo<Any>()
x.extBar<Any>() x /*as Bar<Any> */.extBar<Any>()
} }
fun test_2(x: Any) { fun test_2(x: Any) {
@@ -38,8 +38,8 @@ fun test_2(x: Any) {
x /*as Bar<Any> */ as Foo<Any>? /*~> Unit */ x /*as Bar<Any> */ as Foo<Any>? /*~> Unit */
CHECK_NOT_NULL<Any>(arg0 = x) /*as Foo<Any> */.foo() CHECK_NOT_NULL<Any>(arg0 = x) /*as Foo<Any> */.foo()
CHECK_NOT_NULL<Any>(arg0 = x) /*as Bar<Any> */.bar() CHECK_NOT_NULL<Any>(arg0 = x) /*as Bar<Any> */.bar()
CHECK_NOT_NULL<Any>(arg0 = x).extFoo<Any>() CHECK_NOT_NULL<Any>(arg0 = x) /*as Foo<Any> */.extFoo<Any>()
CHECK_NOT_NULL<Any>(arg0 = x).extBar<Any>() CHECK_NOT_NULL<Any>(arg0 = x) /*as Bar<Any> */.extBar<Any>()
} }
fun test_3(x: Any) { fun test_3(x: Any) {
@@ -65,13 +65,13 @@ fun test_3(x: Any) {
EQEQ(arg0 = tmp_2, arg1 = null) -> materialize<Any>() EQEQ(arg0 = tmp_2, arg1 = null) -> materialize<Any>()
else -> tmp_2 else -> tmp_2
} }
}.extFoo<Any>() } /*as Foo<Any> */.extFoo<Any>()
{ // BLOCK { // BLOCK
val tmp_3: Any = x val tmp_3: Any = x
when { when {
EQEQ(arg0 = tmp_3, arg1 = null) -> materialize<Any>() EQEQ(arg0 = tmp_3, arg1 = null) -> materialize<Any>()
else -> tmp_3 else -> tmp_3
} }
}.extBar<Any>() } /*as Bar<Any> */.extBar<Any>()
} }
@@ -53,9 +53,8 @@ FILE fqName:<root> fileName:/smartCastsWithDestructuring.kt
GET_VAR 'x: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null GET_VAR 'x: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
VAR name:c1 type:kotlin.Int [val] VAR name:c1 type:kotlin.Int [val]
CALL 'public final fun component1 (): kotlin.Int declared in <root>' type=kotlin.Int origin=COMPONENT_N(index=1) CALL 'public final fun component1 (): kotlin.Int declared in <root>' type=kotlin.Int origin=COMPONENT_N(index=1)
$receiver: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any $receiver: GET_VAR 'val tmp_0: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
GET_VAR 'val tmp_0: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
VAR name:c2 type:kotlin.String [val] VAR name:c2 type:kotlin.String [val]
CALL 'public final fun component2 (): kotlin.String declared in <root>' type=kotlin.String origin=COMPONENT_N(index=2) CALL 'public final fun component2 (): kotlin.String declared in <root>' type=kotlin.String origin=COMPONENT_N(index=2)
$receiver: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any $receiver: TYPE_OP type=<root>.I2 origin=IMPLICIT_CAST typeOperand=<root>.I2
GET_VAR 'val tmp_0: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null GET_VAR 'val tmp_0: <root>.I1 declared in <root>.test' type=<root>.I1 origin=null
@@ -19,6 +19,6 @@ fun test(x: I1) {
x !is I2 -> return Unit x !is I2 -> return Unit
} }
val tmp_0: I1 = x /*as Any */ val tmp_0: I1 = x /*as Any */
val c1: Int = tmp_0 /*as Any */.component1() val c1: Int = tmp_0.component1()
val c2: String = tmp_0 /*as Any */.component2() val c2: String = tmp_0 /*as I2 */.component2()
} }
@@ -1576,6 +1576,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1642,6 +1648,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("javaSyntheticGenericPropretyAccess.kt") @TestMetadata("javaSyntheticGenericPropretyAccess.kt")
public void testJavaSyntheticGenericPropretyAccess() throws Exception { public void testJavaSyntheticGenericPropretyAccess() throws Exception {
@@ -1268,6 +1268,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase {
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
runTest("compiler/testData/ir/irText/expressions/identity.kt"); runTest("compiler/testData/ir/irText/expressions/identity.kt");
@@ -1308,6 +1313,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase {
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@TestMetadata("kt16905.kt") @TestMetadata("kt16905.kt")
public void testKt16905() throws Exception { public void testKt16905() throws Exception {
runTest("compiler/testData/ir/irText/expressions/kt16905.kt"); runTest("compiler/testData/ir/irText/expressions/kt16905.kt");
@@ -1438,6 +1438,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1486,6 +1492,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("kt16905.kt") @TestMetadata("kt16905.kt")
public void testKt16905() throws Exception { public void testKt16905() throws Exception {
@@ -1438,6 +1438,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest {
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1486,6 +1492,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest {
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("kt16905.kt") @TestMetadata("kt16905.kt")
public void testKt16905() throws Exception { public void testKt16905() throws Exception {
@@ -1438,6 +1438,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest {
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1486,6 +1492,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest {
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("kt16905.kt") @TestMetadata("kt16905.kt")
public void testKt16905() throws Exception { public void testKt16905() throws Exception {
@@ -1438,6 +1438,12 @@ public class ClassicNativeIrTextTestGenerated extends AbstractClassicNativeIrTex
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1486,6 +1492,12 @@ public class ClassicNativeIrTextTestGenerated extends AbstractClassicNativeIrTex
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("kt16905.kt") @TestMetadata("kt16905.kt")
public void testKt16905() throws Exception { public void testKt16905() throws Exception {
@@ -1438,6 +1438,12 @@ public class FirLightTreeNativeIrTextTestGenerated extends AbstractFirLightTreeN
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1486,6 +1492,12 @@ public class FirLightTreeNativeIrTextTestGenerated extends AbstractFirLightTreeN
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("kt16905.kt") @TestMetadata("kt16905.kt")
public void testKt16905() throws Exception { public void testKt16905() throws Exception {
@@ -1438,6 +1438,12 @@ public class FirPsiNativeIrTextTestGenerated extends AbstractFirPsiNativeIrTextT
runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt");
} }
@Test
@TestMetadata("genericReceiverOnExtensionWithSmartcast.kt")
public void testGenericReceiverOnExtensionWithSmartcast() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericReceiverOnExtensionWithSmartcast.kt");
}
@Test @Test
@TestMetadata("identity.kt") @TestMetadata("identity.kt")
public void testIdentity() throws Exception { public void testIdentity() throws Exception {
@@ -1486,6 +1492,12 @@ public class FirPsiNativeIrTextTestGenerated extends AbstractFirPsiNativeIrTextT
runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt");
} }
@Test
@TestMetadata("intersectedSmartcastForExtensionReceiverWithSameConstructor.kt")
public void testIntersectedSmartcastForExtensionReceiverWithSameConstructor() throws Exception {
runTest("compiler/testData/ir/irText/expressions/intersectedSmartcastForExtensionReceiverWithSameConstructor.kt");
}
@Test @Test
@TestMetadata("kt16905.kt") @TestMetadata("kt16905.kt")
public void testKt16905() throws Exception { public void testKt16905() throws Exception {