Fix intersection type handling in PSI2IR

This commit is contained in:
Dmitry Petrov
2020-02-20 19:13:33 +03:00
parent 1624327ba4
commit e9a7be4a46
16 changed files with 463 additions and 76 deletions
@@ -299,19 +299,19 @@ internal class InsertImplicitCasts(
null
private fun IrExpression.cast(
expectedType: KotlinType?,
originalExpectedType: KotlinType? = expectedType,
possiblyNonDenotableExpectedType: KotlinType?,
originalExpectedType: KotlinType? = possiblyNonDenotableExpectedType,
isLambdaReturnValue: Boolean = false
): IrExpression {
if (expectedType == null) return this
if (expectedType.isError) return this
if (possiblyNonDenotableExpectedType == null) return this
if (possiblyNonDenotableExpectedType.isError) return this
val expectedType = typeTranslator.approximate(possiblyNonDenotableExpectedType)
if (this is IrFunctionExpression && originalExpectedType != null) {
recordExpectedLambdaReturnTypeIfAppropriate(expectedType, originalExpectedType)
}
// TODO here we can have non-denotable KotlinTypes (both in 'this@cast.type' and 'expectedType').
val notNullableExpectedType = expectedType.makeNotNullable()
val valueType = this.type.originalKotlinType!!