Skip to content

Commit 1f6a5f8

Browse files
dzharkovSpace Team
authored andcommitted
FE: Add expected type as EQ constraint for operators at assignments RHS
Thus preventing unexpected too strict casts to more precise types than needed. For constructions like `val x: A = when { .. }`, we add `Kv === A` constraint to the synthetic call for this when. While generally, it looks inconsistent and doesn't really make sense (for calls we would add only `Kv <: A` constraint), it helps to force inferring potentially less precise `A` for the whole when-expression (see the fix for KT-65882). Though, we specifically skipped this rule for assignments because their RHSs might be more precise and providing information for smart casts. But that actually led to the same problems as being solved at KT-65882 just in case of assignments (see fixed issues). But not to lose smart cast information, we compute it as a CST of branches and store at a dedicated type attribute used only in DFA. This solution doesn't look less hacky than the existing solution, but hopefully it helps with the issues and hopefully might be overcome via KT-81083, which assumes a more general approach. ^KT-77008 Fixed ^KT-78127 Fixed ^KT-74588 Fixed ^KT-80208 Fixed
1 parent 6207b67 commit 1f6a5f8

File tree

17 files changed

+139
-43
lines changed

17 files changed

+139
-43
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2010-2025 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package org.jetbrains.kotlin.fir.types
7+
8+
import kotlin.reflect.KClass
9+
10+
/**
11+
* Needed for the case when the type used for smart casts might differ from the actual expression type.
12+
*
13+
* It might happen because we add equality constraint with the expected type to preserve K1 semantics.
14+
* See [org.jetbrains.kotlin.fir.resolve.inference.FirCallCompleter.isSyntheticFunctionCallThatShouldUseEqualityConstraint]
15+
*
16+
* Hopefully, we'll be able to remove it once KT-81083 is fixed.
17+
*/
18+
class RefinedTypeForDataFlowTypeAttribute(
19+
override val coneType: ConeKotlinType,
20+
) : ConeAttributeWithConeType<RefinedTypeForDataFlowTypeAttribute>() {
21+
override fun union(other: RefinedTypeForDataFlowTypeAttribute?): RefinedTypeForDataFlowTypeAttribute? = null
22+
override fun intersect(other: RefinedTypeForDataFlowTypeAttribute?): RefinedTypeForDataFlowTypeAttribute? = null
23+
override fun add(other: RefinedTypeForDataFlowTypeAttribute?): RefinedTypeForDataFlowTypeAttribute = other ?: this
24+
override fun isSubtypeOf(other: RefinedTypeForDataFlowTypeAttribute?): Boolean = true
25+
override fun toString(): String = "{${coneType.renderForDebugging()}=}"
26+
override fun copyWith(newType: ConeKotlinType): RefinedTypeForDataFlowTypeAttribute = RefinedTypeForDataFlowTypeAttribute(newType)
27+
28+
override val key: KClass<out RefinedTypeForDataFlowTypeAttribute>
29+
get() = RefinedTypeForDataFlowTypeAttribute::class
30+
override val keepInInferredDeclarationType: Boolean
31+
get() = true
32+
}
33+
34+
val ConeAttributes.refinedTypeForDataFlow: RefinedTypeForDataFlowTypeAttribute? by ConeAttributes.attributeAccessor<RefinedTypeForDataFlowTypeAttribute>()
35+
36+
val ConeKotlinType.refinedTypeForDataFlowOrSelf: ConeKotlinType
37+
get() = attributes.refinedTypeForDataFlow?.coneType ?: this

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/candidate/Candidate.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,14 @@ class Candidate(
347347
return ConeSimpleLeafResolutionAtom(newExpression, allowUnresolvedExpression = false)
348348
}
349349

350+
// This thing is mostly for a common fast-path optimization and should not affect the semantics once it's set to `true`
351+
var wasExpectedTypeAddedAsEqualityForSyntheticCall: Boolean = false
352+
private set
353+
354+
fun markWasExpectedTypeAddedAsEqualityForSyntheticCall() {
355+
wasExpectedTypeAddedAsEqualityForSyntheticCall = true
356+
}
357+
350358
// ---------------------------------------- Backing field ----------------------------------------
351359

352360
var hasVisibleBackingField: Boolean = false

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,19 @@ import org.jetbrains.kotlin.contracts.description.LogicOperationKind
1212
import org.jetbrains.kotlin.contracts.description.canBeRevisited
1313
import org.jetbrains.kotlin.descriptors.isObject
1414
import org.jetbrains.kotlin.fir.*
15-
import org.jetbrains.kotlin.fir.contracts.description.ConeBooleanExpression
16-
import org.jetbrains.kotlin.fir.contracts.description.ConeConditionalEffectDeclaration
17-
import org.jetbrains.kotlin.fir.contracts.description.ConeConditionalReturnsDeclaration
18-
import org.jetbrains.kotlin.fir.contracts.description.ConeContractConstantValues
19-
import org.jetbrains.kotlin.fir.contracts.description.ConeHoldsInEffectDeclaration
20-
import org.jetbrains.kotlin.fir.contracts.description.ConeReturnsEffectDeclaration
15+
import org.jetbrains.kotlin.fir.contracts.description.*
2116
import org.jetbrains.kotlin.fir.declarations.*
2217
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
2318
import org.jetbrains.kotlin.fir.declarations.utils.lambdaArgumentParent
2419
import org.jetbrains.kotlin.fir.expressions.*
25-
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
26-
import org.jetbrains.kotlin.fir.references.FirPropertyWithExplicitBackingFieldResolvedNamedReference
27-
import org.jetbrains.kotlin.fir.references.symbol
28-
import org.jetbrains.kotlin.fir.references.toResolvedBaseSymbol
29-
import org.jetbrains.kotlin.fir.references.toResolvedPropertySymbol
30-
import org.jetbrains.kotlin.fir.resolve.ImplicitValueStorage
20+
import org.jetbrains.kotlin.fir.references.*
21+
import org.jetbrains.kotlin.fir.resolve.*
3122
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitValue
3223
import org.jetbrains.kotlin.fir.resolve.calls.candidate.candidate
33-
import org.jetbrains.kotlin.fir.resolve.codeFragmentContext
3424
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
35-
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
36-
import org.jetbrains.kotlin.fir.resolve.tryAccessExplicitFieldSymbol
3725
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
3826
import org.jetbrains.kotlin.fir.resolve.substitution.chain
3927
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
40-
import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol
41-
import org.jetbrains.kotlin.fir.resolve.toSymbol
4228
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirAbstractBodyResolveTransformer
4329
import org.jetbrains.kotlin.fir.resolve.transformers.unwrapAtoms
4430
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
@@ -51,8 +37,6 @@ import org.jetbrains.kotlin.fir.types.*
5137
import org.jetbrains.kotlin.name.StandardClassIds
5238
import org.jetbrains.kotlin.types.ConstantValueKind
5339
import org.jetbrains.kotlin.types.SmartcastStability
54-
import kotlin.collections.orEmpty
55-
import kotlin.collections.plus
5640

5741
class DataFlowAnalyzerContext private constructor(
5842
private val session: FirSession,
@@ -1341,7 +1325,7 @@ abstract class FirDataFlowAnalyzer(
13411325
fun exitVariableAssignment(assignment: FirVariableAssignment) {
13421326
val property = assignment.calleeReference?.toResolvedPropertySymbol()?.fir
13431327
if (property != null && property.isLocal) {
1344-
context.variableAssignmentAnalyzer.visitAssignment(property, assignment.rValue.resolvedType)
1328+
context.variableAssignmentAnalyzer.visitAssignment(property, assignment.rValue.resolvedType.refinedTypeForDataFlowOrSelf)
13451329
}
13461330

13471331
graphBuilder.exitVariableAssignment(assignment).mergeIncomingFlow { _, flow ->

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class FirCallCompleter(
197197
// compiler/testData/diagnostics/tests/inference/nestedIfWithExpectedType.kt.
198198
resolutionMode.forceFullCompletion && candidate.isSyntheticFunctionCallThatShouldUseEqualityConstraint(expectedType) -> {
199199
system.addEqualityConstraintIfCompatible(initialType, expectedType, ConeExpectedTypeConstraintPosition)
200+
candidate.markWasExpectedTypeAddedAsEqualityForSyntheticCall()
200201
}
201202
resolutionMode.fromCast -> {
202203
if (candidate.isFunctionForExpectTypeFromCastFeature()) {
@@ -248,7 +249,7 @@ class FirCallCompleter(
248249
private fun Candidate.isSyntheticFunctionCallThatShouldUseEqualityConstraint(expectedType: ConeKotlinType): Boolean {
249250
// If we're inside an assignment's RHS, we mustn't add an equality constraint because it might prevent smartcasts.
250251
// Example: val x: String? = null; x = if (foo) "" else throw Exception()
251-
if (components.context.isInsideAssignmentRhs) return false
252+
if (!LanguageFeature.EqualityConstraintForOperatorsUnderAssignments.isEnabled() && components.context.isInsideAssignmentRhs) return false
252253

253254
val symbol = symbol as? FirCallableSymbol ?: return false
254255
if (symbol.origin != FirDeclarationOrigin.Synthetic.FakeFunction ||

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fakeElement
1212
import org.jetbrains.kotlin.fir.*
1313
import org.jetbrains.kotlin.fir.declarations.*
1414
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty
15-
import org.jetbrains.kotlin.fir.declarations.utils.hasExplicitBackingField
1615
import org.jetbrains.kotlin.fir.declarations.utils.isInline
1716
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
1817
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
@@ -50,7 +49,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
5049
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
5150
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
5251
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
53-
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
5452
import org.jetbrains.kotlin.fir.types.*
5553
import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef
5654
import org.jetbrains.kotlin.fir.types.builder.buildStarProjection
@@ -59,12 +57,15 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
5957
import org.jetbrains.kotlin.fir.visitors.FirTransformer
6058
import org.jetbrains.kotlin.fir.visitors.TransformData
6159
import org.jetbrains.kotlin.fir.visitors.transformSingle
60+
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
6261
import org.jetbrains.kotlin.resolve.calls.inference.model.InferredEmptyIntersection
6362
import org.jetbrains.kotlin.resolve.calls.tower.ApplicabilityDetail
6463
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
64+
import org.jetbrains.kotlin.types.AbstractTypeChecker
6565
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
6666
import org.jetbrains.kotlin.types.Variance
6767
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
68+
import org.jetbrains.kotlin.types.model.isError
6869
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
6970
import org.jetbrains.kotlin.utils.addToStdlib.runIf
7071
import org.jetbrains.kotlin.utils.addToStdlib.runUnless
@@ -1133,7 +1134,14 @@ class FirCallCompletionResultsWriterTransformer(
11331134
whenExpression: FirWhenExpression,
11341135
data: ExpectedArgumentType?,
11351136
): FirStatement {
1136-
return transformSyntheticCall(whenExpression, data).apply {
1137+
return transformSyntheticCallWithDataFlowTypeRefining(
1138+
whenExpression, data
1139+
) {
1140+
when {
1141+
isProperlyExhaustive -> branches.map { it.result.resultType }
1142+
else -> null
1143+
}
1144+
}.apply {
11371145
replaceReturnTypeIfNotExhaustive(session)
11381146
}
11391147
}
@@ -1142,20 +1150,81 @@ class FirCallCompletionResultsWriterTransformer(
11421150
tryExpression: FirTryExpression,
11431151
data: ExpectedArgumentType?,
11441152
): FirStatement {
1145-
return transformSyntheticCall(tryExpression, data)
1153+
return transformSyntheticCallWithDataFlowTypeRefining(
1154+
tryExpression, data
1155+
) {
1156+
buildList {
1157+
add(tryBlock.resultType)
1158+
catches.mapTo(this) { it.block.resultType }
1159+
}
1160+
}
11461161
}
11471162

11481163
override fun transformCheckNotNullCall(
11491164
checkNotNullCall: FirCheckNotNullCall,
11501165
data: ExpectedArgumentType?,
11511166
): FirStatement {
1152-
return transformSyntheticCall(checkNotNullCall, data)
1167+
return transformSyntheticCallWithDataFlowTypeRefining(
1168+
checkNotNullCall,
1169+
data
1170+
) {
1171+
listOf(argumentList.arguments[0].resultType.makeConeTypeDefinitelyNotNullOrNotNull(session.typeContext))
1172+
}
1173+
}
1174+
1175+
/**
1176+
* Transforms synthetic call as usual plus adding RefinedTypeForDataFlowTypeAttribute if branches have more precise types
1177+
* than the inferred expression type.
1178+
*
1179+
* It might happen because we add equality constraint with the expected type to preserve K1 semantics.
1180+
* See [org.jetbrains.kotlin.fir.resolve.inference.FirCallCompleter.isSyntheticFunctionCallThatShouldUseEqualityConstraint]
1181+
*/
1182+
private inline fun <reified D> transformSyntheticCallWithDataFlowTypeRefining(
1183+
syntheticCall: D,
1184+
data: ExpectedArgumentType?,
1185+
computeBranchTypes: D.() -> List<ConeKotlinType>?,
1186+
): D where D : FirResolvable, D : FirExpression {
1187+
// Having this variable before `transformSyntheticCall` is crucial because after there would be no candidate left
1188+
val wasExpectedTypeAddedAsEqualityForSyntheticCall = syntheticCall.wasExpectedTypeAddedAsEqualityForSyntheticCall()
1189+
return transformSyntheticCall(syntheticCall, data).apply {
1190+
if (wasExpectedTypeAddedAsEqualityForSyntheticCall &&
1191+
LanguageFeature.EqualityConstraintForOperatorsUnderAssignments.isEnabled()
1192+
) {
1193+
computeBranchTypes()?.let { branchTypes -> addRefinedTypeForDataFlow(branchTypes) }
1194+
}
1195+
}
1196+
}
1197+
1198+
private fun FirResolvable.wasExpectedTypeAddedAsEqualityForSyntheticCall(): Boolean =
1199+
candidate()?.wasExpectedTypeAddedAsEqualityForSyntheticCall == true
1200+
1201+
/**
1202+
* Adds RefinedTypeForDataFlowTypeAttribute if CST of the branch types differs from the current type.
1203+
*/
1204+
private fun FirExpression.addRefinedTypeForDataFlow(branchTypes: List<ConeKotlinType>): Unit = context(session.typeContext) {
1205+
val currentType = resultType
1206+
if (currentType.isUnitOrFlexibleUnit) return
1207+
if (branchTypes.any { type -> type.contains { it.isError() } }) return
1208+
1209+
val refinedTypeForDataFlow = NewCommonSuperTypeCalculator.commonSuperType(branchTypes) as ConeKotlinType
1210+
1211+
if (!refinedTypeForDataFlow.isUnitOrFlexibleUnit &&
1212+
currentType != refinedTypeForDataFlow &&
1213+
// the refined type doesn't contradict the expression type
1214+
AbstractTypeChecker.isSubtypeOf(session.typeContext, refinedTypeForDataFlow, currentType)
1215+
) {
1216+
resultType = currentType.withAttributes(
1217+
currentType.attributes.add(RefinedTypeForDataFlowTypeAttribute(refinedTypeForDataFlow))
1218+
)
1219+
}
11531220
}
11541221

11551222
override fun transformElvisExpression(
11561223
elvisExpression: FirElvisExpression,
11571224
data: ExpectedArgumentType?,
11581225
): FirStatement {
1226+
// We don't call transformSyntheticCallWithDataFlowTypeRefining for elvis because currently they're being
1227+
// treated very specially at FirControlFlowStatementsResolveTransformer.transformElvisExpression
11591228
return transformSyntheticCall(elvisExpression, data)
11601229
}
11611230

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
77

88
import org.jetbrains.kotlin.config.LanguageFeature
99
import org.jetbrains.kotlin.descriptors.ClassKind
10-
import org.jetbrains.kotlin.fir.FirElement
11-
import org.jetbrains.kotlin.fir.FirSession
12-
import org.jetbrains.kotlin.fir.SessionAndScopeSessionHolder
13-
import org.jetbrains.kotlin.fir.correspondingProperty
10+
import org.jetbrains.kotlin.fir.*
1411
import org.jetbrains.kotlin.fir.declarations.*
1512
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
1613
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
@@ -22,7 +19,6 @@ import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
2219
import org.jetbrains.kotlin.fir.extensions.extensionService
2320
import org.jetbrains.kotlin.fir.extensions.replSnippetResolveExtensions
2421
import org.jetbrains.kotlin.fir.extensions.scriptResolutionHacksComponent
25-
import org.jetbrains.kotlin.fir.languageVersionSettings
2622
import org.jetbrains.kotlin.fir.resolve.*
2723
import org.jetbrains.kotlin.fir.resolve.calls.*
2824
import org.jetbrains.kotlin.fir.resolve.dfa.DataFlowAnalyzerContext
@@ -34,7 +30,6 @@ import org.jetbrains.kotlin.fir.scopes.computeImportingScopes
3430
import org.jetbrains.kotlin.fir.scopes.createImportingScopes
3531
import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope
3632
import org.jetbrains.kotlin.fir.scopes.impl.FirMemberTypeParameterScope
37-
import org.jetbrains.kotlin.fir.shouldSuppressInlineContextAt
3833
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol
3934
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
4035
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
@@ -90,6 +85,7 @@ class BodyResolveContext(
9085
@set:PrivateForInline
9186
var inferenceSession: FirInferenceSession = FirInferenceSession.DEFAULT
9287

88+
// TODO: Remove it once LanguageFeature.EqualityConstraintForOperatorsUnderAssignments is gone KT-81144
9389
@set:PrivateForInline
9490
var isInsideAssignmentRhs: Boolean = false
9591

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,12 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirAbstractBodyRes
279279
if (result.resolvedType.let { it !is ConeTypeVariableType && it.isNullableType() }) {
280280
val rhsResolvedType = result.rhs.resolvedType
281281
// This part of the code is a kind of workaround, and it probably will be resolved by KT-55692
282-
if (!rhsResolvedType.isNullableType()) {
282+
if (!rhsResolvedType.refinedTypeForDataFlowOrSelf.isNullableType()) {
283283
// It's definitely not a flexible with nullable bound
284284
// Sometimes return type for special call for elvis operator might be nullable,
285285
// but result is not nullable if the right type is not nullable
286286
result.replaceConeTypeOrNull(result.resolvedType.makeConeTypeDefinitelyNotNullOrNotNull(session.typeContext))
287-
} else if (rhsResolvedType is ConeFlexibleType && !rhsResolvedType.lowerBound.isNullableType()) {
287+
} else if (isFlexibleWithNotNullable(rhsResolvedType.refinedTypeForDataFlowOrSelf)) {
288288
result.replaceConeTypeOrNull(result.resultType.makeConeFlexibleTypeWithNotNullableLowerBound(session.typeContext))
289289
}
290290
}
@@ -294,6 +294,9 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirAbstractBodyRes
294294
return result
295295
}
296296

297+
private fun ConeInferenceContext.isFlexibleWithNotNullable(rhsResolvedType: ConeKotlinType): Boolean =
298+
rhsResolvedType is ConeFlexibleType && !rhsResolvedType.lowerBound.isNullableType()
299+
297300
private fun computeResolutionModeForElvisLHS(
298301
data: ResolutionMode,
299302
): ResolutionMode {

compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/model.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.DfaType
1010
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
1111
import org.jetbrains.kotlin.fir.types.ConeErrorType
1212
import org.jetbrains.kotlin.fir.types.ConeKotlinType
13+
import org.jetbrains.kotlin.fir.types.refinedTypeForDataFlowOrSelf
1314
import kotlin.contracts.ExperimentalContracts
1415
import kotlin.contracts.contract
1516

@@ -56,7 +57,7 @@ infix fun RealVariable.valueNotEq(boolean: Boolean): MutableTypeStatement =
5657
MutableTypeStatement(this, lowerTypes = linkedSetOf(DfaType.BooleanLiteral(boolean)))
5758

5859
infix fun DataFlowVariable.typeEq(type: ConeKotlinType): MutableTypeStatement =
59-
MutableTypeStatement(this, if (type is ConeErrorType) linkedSetOf() else linkedSetOf(type))
60+
MutableTypeStatement(this, if (type is ConeErrorType) linkedSetOf() else linkedSetOf(type.refinedTypeForDataFlowOrSelf))
6061

6162
infix fun DataFlowVariable.typeNotEq(type: ConeKotlinType): MutableTypeStatement =
6263
MutableTypeStatement(this, lowerTypes = if (type is ConeErrorType) linkedSetOf() else linkedSetOf(DfaType.Cone(type)))

compiler/testData/codegen/box/inference/ifWithAssignmentAndNothingBranch.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_K2: ANY
21
// ISSUE: KT-78127
32

43
fun <T : Any> materialize(): T {

compiler/testData/codegen/box/inference/noCheckNotNullForFlexibleTypeInWhenAtAssignment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// IGNORE_BACKEND_K2: ANY
21
// TARGET_BACKEND: JVM
32
// ISSUE: KT-74588
43

0 commit comments

Comments
 (0)