FIR: Fix incorrect type of block generated for inc operator
Previously, it was obtained from expected type of a variable being assigned,
but it's better to use the type of resulting expression
Initially this part was brought in 4ab0897d7d,
but as we see in commit message and tests it was all about unit-coercion
This commit is contained in:
committed by
teamcityserver
parent
a7859e0332
commit
c0b6a593e0
+2
-2
@@ -408,8 +408,8 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
TransformData.Data(value)
|
||||
}
|
||||
block.transformOtherChildren(transformer, data)
|
||||
if (data is ResolutionMode.WithExpectedType && data.expectedTypeRef is FirResolvedTypeRef) {
|
||||
// Top-down propagation: from the explicit type of the enclosing declaration to the block type
|
||||
if (data is ResolutionMode.WithExpectedType && data.expectedTypeRef.coneTypeSafe<ConeKotlinType>()?.isUnitOrFlexibleUnit == true) {
|
||||
// Unit-coercion
|
||||
block.resultType = data.expectedTypeRef
|
||||
} else {
|
||||
// Bottom-up propagation: from the return type of the last expression in the block to the block type
|
||||
|
||||
Reference in New Issue
Block a user