[FIR] Use type without smartcast for local variable with smartcasted initializer

This commit is contained in:
Dmitriy Novozhilov
2021-02-15 12:26:13 +03:00
parent 40e286b354
commit d4c26cca52
24 changed files with 253 additions and 159 deletions
@@ -37446,6 +37446,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@Test
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@Test @Test
@TestMetadata("lambdaArgumentWithoutType.kt") @TestMetadata("lambdaArgumentWithoutType.kt")
public void testLambdaArgumentWithoutType() throws Exception { public void testLambdaArgumentWithoutType() throws Exception {
@@ -989,7 +989,8 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
if (variable.returnTypeRef is FirImplicitTypeRef) { if (variable.returnTypeRef is FirImplicitTypeRef) {
when { when {
initializer != null -> { initializer != null -> {
val expectedType = when (val resultType = initializer.resultType) { val unwrappedInitializer = (initializer as? FirExpressionWithSmartcast)?.originalExpression ?: initializer
val expectedType = when (val resultType = unwrappedInitializer.resultType) {
is FirImplicitTypeRef -> buildErrorTypeRef { is FirImplicitTypeRef -> buildErrorTypeRef {
diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError) diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError)
} }
+40
View File
@@ -0,0 +1,40 @@
// ISSUE: KT-44932
// WITH_STDLIB
abstract class PsiElement {
abstract val parent: PsiElement
}
class KtNameReferenceExpression(override val parent: PsiElement) : PsiElement()
class OtherElement(override val parent: PsiElement) : PsiElement()
class KtDotQualifiedExpression : PsiElement() {
override val parent: PsiElement
get() = this
val psi: PsiElement = EndElement()
}
class EndElement : PsiElement() {
override val parent: PsiElement
get() = this
}
fun mark(element: PsiElement): String {
when (element) {
is KtNameReferenceExpression -> {
var parent = element
repeat(2) {
parent = parent.parent
(parent as? KtDotQualifiedExpression)?.psi?.let { return mark(it) }
}
}
}
return if (element is EndElement) "OK" else "Fail"
}
fun box(): String {
val element = KtNameReferenceExpression(OtherElement(KtDotQualifiedExpression()))
return mark(element)
}
@@ -22,7 +22,7 @@ fun test2() {
} }
<set-x>(<set-?> = 0) <set-x>(<set-?> = 0)
val <unary>: Int = <get-x>() val <unary>: Int? = <get-x>()
<set-x>(<set-?> = <unary>.inc()) <set-x>(<set-?> = <unary>.inc())
<unary> /*~> Unit */ <unary> /*~> Unit */
<set-x>(<set-?> = <get-x>().plus(other = 1)) <set-x>(<set-?> = <get-x>().plus(other = 1))
@@ -47,13 +47,13 @@ FILE fqName:<root> fileName:/localDelegatedProperties.kt
value: GET_VAR '<set-?>: kotlin.Int? declared in <root>.test2.<set-x>' type=kotlin.Int? origin=null value: GET_VAR '<set-?>: kotlin.Int? declared in <root>.test2.<set-x>' type=kotlin.Int? origin=null
CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ
<set-?>: CONST Int type=kotlin.Int value=0 <set-?>: CONST Int type=kotlin.Int value=0
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val]
CALL 'local final fun <get-x> (): kotlin.Int? declared in <root>.test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY CALL 'local final fun <get-x> (): kotlin.Int? declared in <root>.test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY
CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ
<set-?>: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null <set-?>: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null $this: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in <root>.test2' type=kotlin.Int? origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null GET_VAR 'val tmp_0: kotlin.Int? [val] declared in <root>.test2' type=kotlin.Int? origin=null
CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ
<set-?>: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null <set-?>: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: CALL 'local final fun <get-x> (): kotlin.Int? declared in <root>.test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY $this: CALL 'local final fun <get-x> (): kotlin.Int? declared in <root>.test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY
@@ -63,8 +63,8 @@ fun test4(fn: Function1<Int, Unit>) {
when { when {
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>>: Function1<Int, Unit> = fn /*as IFoo */
<<array>>.set(i = <<index_0>>, newValue = <<array>>.get(i = <<index_0>>).plus(other = 1)) <<array>>.set(i = <<index_0>> /*as IFoo */, newValue = <<array>>.get(i = <<index_0>> /*as IFoo */).plus(other = 1))
} }
} }
} }
@@ -73,8 +73,8 @@ fun test5(a: Any) {
a as Function1<Int, Unit> /*~> Unit */ a as Function1<Int, Unit> /*~> Unit */
{ // BLOCK { // BLOCK
val <<array>>: A = A val <<array>>: A = A
val <<index_0>>: Function1<Int, Unit> = a /*as Function1<Int, Unit> */ val <<index_0>>: Any = 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>> /*as Function1<Int, Unit> */ /*-> IFoo */, newValue = <<array>>.get(i = <<index_0>> /*as Function1<Int, Unit> */ /*-> IFoo */).plus(other = 1))
} }
} }
@@ -83,8 +83,8 @@ fun test6(a: Any) {
a /*as Function1<Int, Unit> */ as IFoo /*~> Unit */ a /*as Function1<Int, Unit> */ as IFoo /*~> Unit */
{ // BLOCK { // BLOCK
val <<array>>: A = A val <<array>>: A = A
val <<index_0>>: Function1<Int, Unit> = a /*as Function1<Int, Unit> */ val <<index_0>>: Any = a /*as Function1<Int, Unit> */
<<array>>.set(i = <<index_0>>, newValue = <<array>>.get(i = <<index_0>>).plus(other = 1)) <<array>>.set(i = <<index_0>> /*as Function1<Int, Unit> */, newValue = <<array>>.get(i = <<index_0>> /*as Function1<Int, Unit> */).plus(other = 1))
} }
} }
@@ -136,16 +136,18 @@ FILE fqName:<root> fileName:/caoWithAdaptationForSam.kt
then: BLOCK type=kotlin.Unit origin=null then: BLOCK type=kotlin.Unit origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:<root>.A [val] VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:<root>.A [val]
GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:<root>.IFoo [val] VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Function1<kotlin.Int, kotlin.Unit> [val]
TYPE_OP type=<root>.IFoo origin=IMPLICIT_CAST typeOperand=<root>.IFoo TYPE_OP type=<root>.IFoo origin=IMPLICIT_CAST typeOperand=<root>.IFoo
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: GET_VAR 'val tmp_3: <root>.IFoo [val] declared in <root>.test4' type=<root>.IFoo origin=null i: TYPE_OP type=<root>.IFoo origin=IMPLICIT_CAST typeOperand=<root>.IFoo
GET_VAR 'val tmp_3: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test4' 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_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: GET_VAR 'val tmp_3: <root>.IFoo [val] declared in <root>.test4' type=<root>.IFoo origin=null i: TYPE_OP type=<root>.IFoo origin=IMPLICIT_CAST typeOperand=<root>.IFoo
GET_VAR 'val tmp_3: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test4' 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
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
@@ -156,18 +158,20 @@ FILE fqName:<root> fileName:/caoWithAdaptationForSam.kt
BLOCK type=kotlin.Unit origin=null BLOCK type=kotlin.Unit origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:<root>.A [val] VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:<root>.A [val]
GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A
VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Function1<kotlin.Int, kotlin.Unit> [val] VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Any [val]
TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit> TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit>
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null GET_VAR 'a: kotlin.Any declared in <root>.test5' 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_4: <root>.A [val] declared in <root>.test5' type=<root>.A origin=null $receiver: GET_VAR 'val tmp_4: <root>.A [val] declared in <root>.test5' type=<root>.A origin=null
i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
GET_VAR 'val tmp_5: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test5' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit>
GET_VAR 'val tmp_5: kotlin.Any [val] declared in <root>.test5' type=kotlin.Any 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_4: <root>.A [val] declared in <root>.test5' type=<root>.A origin=null $receiver: GET_VAR 'val tmp_4: <root>.A [val] declared in <root>.test5' type=<root>.A origin=null
i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo i: TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
GET_VAR 'val tmp_5: kotlin.Function1<kotlin.Int, kotlin.Unit> [val] declared in <root>.test5' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=null TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit>
GET_VAR 'val tmp_5: kotlin.Any [val] declared in <root>.test5' type=kotlin.Any origin=null
other: CONST Int type=kotlin.Int value=1 other: CONST Int type=kotlin.Int value=1
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
@@ -182,14 +186,16 @@ FILE fqName:<root> fileName:/caoWithAdaptationForSam.kt
BLOCK type=kotlin.Unit origin=null BLOCK type=kotlin.Unit origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:<root>.A [val] VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:<root>.A [val]
GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A
VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Function1<kotlin.Int, kotlin.Unit> [val] VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Any [val]
TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit> TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit>
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: 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 i: TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit>
GET_VAR 'val tmp_7: kotlin.Any [val] declared in <root>.test6' type=kotlin.Any 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: 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 i: TYPE_OP type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.Int, kotlin.Unit>
GET_VAR 'val tmp_7: kotlin.Any [val] declared in <root>.test6' type=kotlin.Any origin=null
other: CONST Int type=kotlin.Int value=1 other: CONST Int type=kotlin.Int value=1
@@ -14,9 +14,9 @@ fun test(x: Any) {
x is IC1 -> x /*as IC1 */ is IC2 x is IC1 -> x /*as IC1 */ is IC2
else -> false else -> false
} -> { // BLOCK } -> { // BLOCK
val <destruct>: IC1 = x /*as IC1 */ val <destruct>: Any = x /*as IC1 */
val x1: Int = <destruct>.component1() val x1: Int = <destruct> /*as IC1 */.component1()
val x2: String = <destruct> /*as IC2 */.component2() val x2: String = <destruct> /*as IC1 */ /*as IC2 */.component2()
} }
} }
} }
@@ -49,13 +49,15 @@ FILE fqName:<root> fileName:/multipleSmartCasts.kt
if: CONST Boolean type=kotlin.Boolean value=true if: CONST Boolean type=kotlin.Boolean value=true
then: CONST Boolean type=kotlin.Boolean value=false then: CONST Boolean type=kotlin.Boolean value=false
then: BLOCK type=kotlin.Unit origin=null then: BLOCK type=kotlin.Unit origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.IC1 [val] VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any [val]
TYPE_OP type=<root>.IC1 origin=IMPLICIT_CAST typeOperand=<root>.IC1 TYPE_OP type=<root>.IC1 origin=IMPLICIT_CAST typeOperand=<root>.IC1
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
VAR name:x1 type:kotlin.Int [val] VAR name:x1 type:kotlin.Int [val]
CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in <root>.IC1' type=kotlin.Int origin=null CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in <root>.IC1' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_0: <root>.IC1 [val] declared in <root>.test' type=<root>.IC1 origin=null $this: TYPE_OP type=<root>.IC1 origin=IMPLICIT_CAST typeOperand=<root>.IC1
GET_VAR 'val tmp_0: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
VAR name:x2 type:kotlin.String [val] VAR name:x2 type:kotlin.String [val]
CALL 'public abstract fun component2 (): kotlin.String [operator] declared in <root>.IC2' type=kotlin.String origin=null CALL 'public abstract fun component2 (): kotlin.String [operator] declared in <root>.IC2' type=kotlin.String origin=null
$this: TYPE_OP type=<root>.IC2 origin=IMPLICIT_CAST typeOperand=<root>.IC2 $this: TYPE_OP type=<root>.IC2 origin=IMPLICIT_CAST typeOperand=<root>.IC2
GET_VAR 'val tmp_0: <root>.IC1 [val] declared in <root>.test' type=<root>.IC1 origin=null TYPE_OP type=<root>.IC1 origin=IMPLICIT_CAST typeOperand=<root>.IC1
GET_VAR 'val tmp_0: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
@@ -18,7 +18,7 @@ fun test(x: I1) {
when { when {
x !is I2 -> return Unit x !is I2 -> return Unit
} }
val <destruct>: I2 = x /*as I2 */ val <destruct>: I1 = x /*as I2 */
val c1: Int = <destruct>.component1() val c1: Int = <destruct> /*as I2 */.component1()
val c2: String = <destruct>.component2() val c2: String = <destruct> /*as I2 */.component2()
} }
@@ -48,12 +48,14 @@ 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
then: RETURN type=kotlin.Nothing from='public final fun test (x: <root>.I1): kotlin.Unit declared in <root>' then: RETURN type=kotlin.Nothing from='public final fun test (x: <root>.I1): kotlin.Unit declared in <root>'
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.I2 [val] VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.I1 [val]
TYPE_OP type=<root>.I2 origin=IMPLICIT_CAST typeOperand=<root>.I2 TYPE_OP type=<root>.I2 origin=IMPLICIT_CAST typeOperand=<root>.I2
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 [operator] declared in <root>' type=kotlin.Int origin=null CALL 'public final fun component1 (): kotlin.Int [operator] declared in <root>' type=kotlin.Int origin=null
$receiver: GET_VAR 'val tmp_0: <root>.I2 [val] declared in <root>.test' type=<root>.I2 origin=null $receiver: TYPE_OP type=<root>.I2 origin=IMPLICIT_CAST typeOperand=<root>.I2
GET_VAR 'val tmp_0: <root>.I1 [val] 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 [operator] declared in <root>' type=kotlin.String origin=null CALL 'public final fun component2 (): kotlin.String [operator] declared in <root>' type=kotlin.String origin=null
$receiver: GET_VAR 'val tmp_0: <root>.I2 [val] declared in <root>.test' type=<root>.I2 origin=null $receiver: TYPE_OP type=<root>.I2 origin=IMPLICIT_CAST typeOperand=<root>.I2
GET_VAR 'val tmp_0: <root>.I1 [val] declared in <root>.test' type=<root>.I1 origin=null
@@ -37446,6 +37446,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@Test
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@Test @Test
@TestMetadata("lambdaArgumentWithoutType.kt") @TestMetadata("lambdaArgumentWithoutType.kt")
public void testLambdaArgumentWithoutType() throws Exception { public void testLambdaArgumentWithoutType() throws Exception {
@@ -37446,6 +37446,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@Test
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@Test @Test
@TestMetadata("lambdaArgumentWithoutType.kt") @TestMetadata("lambdaArgumentWithoutType.kt")
public void testLambdaArgumentWithoutType() throws Exception { public void testLambdaArgumentWithoutType() throws Exception {
@@ -29921,6 +29921,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@TestMetadata("lambdaArgumentWithoutType.kt") @TestMetadata("lambdaArgumentWithoutType.kt")
public void testLambdaArgumentWithoutType() throws Exception { public void testLambdaArgumentWithoutType() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt");
@@ -9,8 +9,8 @@ fun case_1() {
val b = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>a<!>) val b = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>a<!>)
val c = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>a<!> val c = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>a<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any")!>c<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>c<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any")!>c<!>.equals(10) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>c<!>.equals(10)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.equals(10) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.equals(10)
} }
@@ -18,8 +18,8 @@ fun case_1() {
fun case_2(a: Any?) { fun case_2(a: Any?) {
if (a is String) { if (a is String) {
val b = a val b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any?")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any?")!>b<!>.length
} }
} }
@@ -30,8 +30,8 @@ fun case_3(a: Any?) {
val c = b val c = b
val d = c val d = c
val e = d val e = d
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>e<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any?")!>e<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>e<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any?")!>e<!>.length
} }
} }
@@ -46,12 +46,12 @@ fun case_4(a: Any?) {
if (d is ClassLevel4) { if (d is ClassLevel4) {
val e = d val e = d
if (e is ClassLevel5) { if (e is ClassLevel5) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & ClassLevel4")!>e<!> <!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & kotlin.Any?")!>e<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & ClassLevel4")!>e<!>.test1() <!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & kotlin.Any?")!>e<!>.test1()
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & ClassLevel4")!>e<!>.test2() <!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & kotlin.Any?")!>e<!>.test2()
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & ClassLevel4")!>e<!>.test3() <!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & kotlin.Any?")!>e<!>.test3()
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & ClassLevel4")!>e<!>.test4() <!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & kotlin.Any?")!>e<!>.test4()
<!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & ClassLevel4")!>e<!>.test5() <!DEBUG_INFO_EXPRESSION_TYPE("ClassLevel5 & kotlin.Any?")!>e<!>.test5()
} }
} }
} }
@@ -13,8 +13,8 @@ fun case_1() {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.equals(10) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.equals(10)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any")!>c<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>c<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any")!>c<!>.equals(10) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Any?")!>c<!>.equals(10)
} }
// TESTCASE NUMBER: 2 // TESTCASE NUMBER: 2
@@ -22,8 +22,8 @@ fun case_2(x: Any) {
if (x is String) { if (x is String) {
val y = x val y = x
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>x<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>y<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>y<!>.length
} }
} }
@@ -34,10 +34,10 @@ fun case_3(x: Any?) {
if (y == null) throw Exception() if (y == null) throw Exception()
var z = y var z = y
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>x<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number?")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number")!>z<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>z<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number?")!>y<!>.toByte() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>y<!>.toByte()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number")!>z<!>.toByte() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>z<!>.toByte()
} }
} }
@@ -48,10 +48,10 @@ fun case_4(x: Any?) {
while (true && y != null) { while (true && y != null) {
var z = y var z = y
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>x<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number?")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number")!>z<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>z<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number?")!>y<!>.toByte() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>y<!>.toByte()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Number")!>z<!>.toByte() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number & kotlin.Any?")!>z<!>.toByte()
} }
} }
} }
@@ -11,16 +11,16 @@ fun case_1() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
while (a is String) { while (a is String) {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.<!UNRESOLVED_REFERENCE!>length<!>
} }
} }
@@ -33,16 +33,16 @@ fun case_2() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
while (true) { while (true) {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.<!UNRESOLVED_REFERENCE!>length<!>
} }
} }
@@ -55,16 +55,16 @@ fun case_3() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
do { do {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} while (true) } while (true)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -77,16 +77,16 @@ fun case_4() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
do { do {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} while (false) } while (false)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -99,16 +99,16 @@ fun case_5() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
for (i in 0..10) { for (i in 0..10) {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.<!UNRESOLVED_REFERENCE!>length<!>
} }
} }
@@ -117,16 +117,16 @@ fun case_6() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
if (a is String) { if (a is String) {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -135,14 +135,14 @@ fun case_7() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
when (true) { when (true) {
true -> b = a true -> b = a
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -155,16 +155,16 @@ fun case_8() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
try { try {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} catch (e: Exception) { } } catch (e: Exception) { }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -173,18 +173,18 @@ fun case_9() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
try { try {
} catch (e: Exception) { } catch (e: Exception) {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -193,18 +193,18 @@ fun case_10() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
try { try {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} finally { } finally {
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -213,18 +213,18 @@ fun case_11() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
try { try {
} finally { } finally {
b = a b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -237,15 +237,15 @@ fun case_12() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
while (if (true) { b = a; true } else true) { while (if (true) { b = a; true } else true) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.<!UNRESOLVED_REFERENCE!>length<!>
} }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.<!UNRESOLVED_REFERENCE!>length<!>
} }
} }
@@ -254,12 +254,12 @@ fun case_13() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
a.plus(if (true) { b = a; true } else true) a.plus(if (true) { b = a; true } else true)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
@@ -272,12 +272,12 @@ fun case_14() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
while (true) { while (true) {
if (true) { b = a; } else 3 if (true) { b = a; } else 3
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>b<!>.<!UNRESOLVED_REFERENCE!>length<!>
} }
} }
} }
@@ -287,12 +287,12 @@ fun case_15() {
var a: Any = 4 var a: Any = 4
if (a is String) { if (a is String) {
var b = a var b = a
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
while (true) { while (true) {
if (true) { b = a; } else { b = a; } if (true) { b = a; } else { b = a; }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String")!>b<!>.length <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.Any")!>b<!>.length
} }
} }
} }
@@ -78,7 +78,7 @@ fun case_6(x: Any?, b: Class) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Any?")!>x<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Any?")!>x<!>
val y = if (true) b::fun_1 else b::fun_1 val y = if (true) b::fun_1 else b::fun_1
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Any?")!>x<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Int")!>z1<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Any?")!>z1<!>
val z2: Int = z1 val z2: Int = z1
} }
@@ -57,16 +57,16 @@ fun case_3(a: Inv<Int>?) {
if (a != null) { if (a != null) {
val b = a val b = a
if (a == null) { if (a == null) {
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.equals(null) <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.propT <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.propT
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.propAny <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.propAny
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.propNullableT <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.propNullableT
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.propNullableAny <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.propNullableAny
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.funT() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.funT()
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.funAny() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.funAny()
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.funNullableT() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.funNullableT()
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>")!>b<!>.funNullableAny() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int> & Inv<kotlin.Int>?")!>b<!>.funNullableAny()
} }
} }
} }
@@ -61,16 +61,16 @@ fun case_3(a: Inv<out Int>?) {
if (a != null) { if (a != null) {
val b = a val b = a
if (a == null) if (a == null)
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!> <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.equals(null) <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.propT <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.propT
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.propAny <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.propAny
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.propNullableT <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.propNullableT
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.propNullableAny <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.propNullableAny
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.funT() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.funT()
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.funAny() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.funAny()
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.funNullableT() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.funNullableT()
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>")!>b<!>.funNullableAny() <!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int> & Inv<out kotlin.Int>?")!>b<!>.funNullableAny()
} }
} }
@@ -25532,6 +25532,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@TestMetadata("lambdaArgumentWithoutType.kt") @TestMetadata("lambdaArgumentWithoutType.kt")
public void testLambdaArgumentWithoutType() throws Exception { public void testLambdaArgumentWithoutType() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt");
@@ -25017,6 +25017,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@TestMetadata("lambdaArgumentWithoutType.kt") @TestMetadata("lambdaArgumentWithoutType.kt")
public void testLambdaArgumentWithoutType() throws Exception { public void testLambdaArgumentWithoutType() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt");
@@ -24977,6 +24977,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@TestMetadata("lambdaArgumentWithoutType.kt") @TestMetadata("lambdaArgumentWithoutType.kt")
public void testLambdaArgumentWithoutType() throws Exception { public void testLambdaArgumentWithoutType() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt");
@@ -13594,6 +13594,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt");
} }
@TestMetadata("kt44932.kt")
public void testKt44932() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt");
}
@TestMetadata("multipleSmartCast.kt") @TestMetadata("multipleSmartCast.kt")
public void testMultipleSmartCast() throws Exception { public void testMultipleSmartCast() throws Exception {
runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt");