diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt index 5a1432bf5d1..83ba29f96bc 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt @@ -94,7 +94,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker { override val canBeNull: Boolean get() = c.dataFlowInfo.getPredictableNullability(dataFlowValue).canBeNull() override val possibleTypes: Set - get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue) + get() = c.dataFlowInfo.getCollectedTypes(dataFlowValue) override val presentableText: String get() = StringUtil.trimMiddle(expression.getText(), 50) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index ae7e3899aa3..a4ef807a288 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -194,7 +194,7 @@ class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeRes val dataFlowValue = DataFlowValueFactory.createDataFlowValue(deparenthesizedArgument, type, context) if (!dataFlowValue.isPredictable) return type - val possibleTypes = context.dataFlowInfo.getPossibleTypes(dataFlowValue) + val possibleTypes = context.dataFlowInfo.getCollectedTypes(dataFlowValue) if (possibleTypes.isEmpty()) return type return TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, possibleTypes + type) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java index 6fa20d9d54a..6c15718618e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java @@ -41,7 +41,7 @@ public interface DataFlowInfo { * Returns collected nullability for the given value, NOT taking its predictability into account. */ @NotNull - Nullability getNullability(@NotNull DataFlowValue key); + Nullability getCollectedNullability(@NotNull DataFlowValue key); /** * Returns collected nullability for the given value if it's predictable. @@ -57,7 +57,7 @@ public interface DataFlowInfo { * are NOT included. So it's quite possible to get an empty set here. */ @NotNull - Set getPossibleTypes(@NotNull DataFlowValue key); + Set getCollectedTypes(@NotNull DataFlowValue key); /** * Returns possible types for the given value if it's predictable. diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java index a6c1dd88f32..e8c09f0e7b9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java @@ -109,7 +109,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @Override @NotNull - public Nullability getNullability(@NotNull DataFlowValue key) { + public Nullability getCollectedNullability(@NotNull DataFlowValue key) { return getNullability(key, false); } @@ -124,7 +124,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL if (predictableOnly && !key.isPredictable()) return key.getImmanentNullability(); Nullability nullability = nullabilityInfo.get(key); return nullability != null ? nullability : - parent != null ? parent.getNullability(key) : + parent != null ? parent.getCollectedNullability(key) : key.getImmanentNullability(); } @@ -134,19 +134,19 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @NotNull Nullability nullability ) { map.put(value, nullability); - return nullability != getNullability(value); + return nullability != getCollectedNullability(value); } @Override @NotNull - public Set getPossibleTypes(@NotNull DataFlowValue key) { - return getPossibleTypes(key, true); + public Set getCollectedTypes(@NotNull DataFlowValue key) { + return getCollectedTypes(key, true); } @NotNull - private Set getPossibleTypes(@NotNull DataFlowValue key, boolean enrichWithNotNull) { + private Set getCollectedTypes(@NotNull DataFlowValue key, boolean enrichWithNotNull) { Set types = collectTypesFromMeAndParents(key); - if (!enrichWithNotNull || getNullability(key).canBeNull()) { + if (!enrichWithNotNull || getCollectedNullability(key).canBeNull()) { return types; } @@ -173,7 +173,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL if (!key.isPredictable()) { return new LinkedHashSet(); } - return getPossibleTypes(key, enrichWithNotNull); + return getCollectedTypes(key, enrichWithNotNull); } /** @@ -271,7 +271,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL } } else { - types.addAll(current.getPossibleTypes(value)); + types.addAll(current.getCollectedTypes(value)); break; } } @@ -296,7 +296,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @NotNull public DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KotlinType type) { if (value.getType().equals(type)) return this; - if (getPossibleTypes(value).contains(type)) return this; + if (getCollectedTypes(value).contains(type)) return this; if (!FlexibleTypesKt.isFlexible(value.getType()) && TypeUtilsKt.isSubtypeOf(value.getType(), type)) return this; ImmutableMap newNullabilityInfo = type.isMarkedNullable() ? EMPTY_NULLABILITY_INFO : ImmutableMap.of(value, NOT_NULL); @@ -318,7 +318,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL for (Map.Entry entry : other.getCompleteNullabilityInfo().entrySet()) { DataFlowValue key = entry.getKey(); Nullability otherFlags = entry.getValue(); - Nullability thisFlags = getNullability(key); + Nullability thisFlags = getCollectedNullability(key); Nullability flags = thisFlags.and(otherFlags); if (flags != thisFlags) { nullabilityMapBuilder.put(key, flags); @@ -352,7 +352,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL for (Map.Entry entry : other.getCompleteNullabilityInfo().entrySet()) { DataFlowValue key = entry.getKey(); Nullability otherFlags = entry.getValue(); - Nullability thisFlags = getNullability(key); + Nullability thisFlags = getCollectedNullability(key); nullabilityMapBuilder.put(key, thisFlags.or(otherFlags)); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java index ccab841758f..b93ffc9db1c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java @@ -116,7 +116,7 @@ public class SmartCastManager { receiverToCast, bindingContext, containingDeclarationOrModule ); - return dataFlowInfo.getPossibleTypes(dataFlowValue); + return dataFlowInfo.getCollectedTypes(dataFlowValue); } public boolean isSubTypeBySmartCastIgnoringNullability( @@ -178,7 +178,7 @@ public class SmartCastManager { @Nullable KtExpression calleeExpression, boolean recordExpressionType ) { - for (KotlinType possibleType : c.dataFlowInfo.getPossibleTypes(dataFlowValue)) { + for (KotlinType possibleType : c.dataFlowInfo.getCollectedTypes(dataFlowValue)) { if (ArgumentTypeResolver.isSubtypeOfForArgumentType(possibleType, expectedType)) { if (expression != null) { recordCastOrError(expression, possibleType, c.trace, dataFlowValue, recordExpressionType); @@ -190,7 +190,7 @@ public class SmartCastManager { } } - if (!c.dataFlowInfo.getNullability(dataFlowValue).canBeNull() && !expectedType.isMarkedNullable()) { + if (!c.dataFlowInfo.getCollectedNullability(dataFlowValue).canBeNull() && !expectedType.isMarkedNullable()) { // Handling cases like: // fun bar(x: Any) {} // fun foo(x: T) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt index 95f0c1a139a..05bc01a32b7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerImpl.kt @@ -125,7 +125,7 @@ private class DataFlowDecoratorImpl(private val resolutionContext: ResolutionCon private fun getSmartCastInfo(receiver: ReceiverValue): SmartCastInfo = cache.getOrPut(receiver) { val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiver, resolutionContext) - SmartCastInfo(dataFlowValue, dataFlowInfo.getPossibleTypes(dataFlowValue)) + SmartCastInfo(dataFlowValue, dataFlowInfo.getCollectedTypes(dataFlowValue)) } override fun getDataFlowValue(receiver: ReceiverValue): DataFlowValue = getSmartCastInfo(receiver).dataFlowValue diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt index 48036552886..546f7012f11 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt @@ -128,7 +128,7 @@ fun KtExpression.guessTypes( val theType1 = context.getType(this) if (theType1 != null) { val dataFlowInfo = context.getDataFlowInfo(this) - val possibleTypes = dataFlowInfo.getPossibleTypes(DataFlowValueFactory.createDataFlowValue(this, theType1, context, module)) + val possibleTypes = dataFlowInfo.getCollectedTypes(DataFlowValueFactory.createDataFlowValue(this, theType1, context, module)) return if (possibleTypes.isNotEmpty()) possibleTypes.toTypedArray() else arrayOf(theType1) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt index cb71c846b13..3fd11b3f8fd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt @@ -182,13 +182,13 @@ data class ExtractionData( val dataFlowInfo = context.getDataFlowInfo(expression) (resolvedCall?.getImplicitReceiverValue() as? ImplicitReceiver)?.let { - return dataFlowInfo.getPossibleTypes(DataFlowValueFactory.createDataFlowValueForStableReceiver(it)) + return dataFlowInfo.getCollectedTypes(DataFlowValueFactory.createDataFlowValueForStableReceiver(it)) } val type = resolvedCall?.resultingDescriptor?.returnType ?: return emptySet() val containingDescriptor = expression.getResolutionScope(context, expression.getResolutionFacade()).ownerDescriptor val dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, type, context, containingDescriptor) - return dataFlowInfo.getPossibleTypes(dataFlowValue) + return dataFlowInfo.getCollectedTypes(dataFlowValue) } fun getBrokenReferencesInfo(body: KtBlockExpression): List { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/inferParameterInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/inferParameterInfo.kt index 02b273a285c..010aa243daf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/inferParameterInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/inferParameterInfo.kt @@ -313,7 +313,7 @@ private fun suggestParameterType( receiverToExtract is ImplicitReceiver -> { val typeByDataFlowInfo = if (useSmartCastsIfPossible) { val dataFlowInfo = bindingContext.getDataFlowInfo(resolvedCall!!.call.callElement) - val possibleTypes = dataFlowInfo.getPossibleTypes(DataFlowValueFactory.createDataFlowValueForStableReceiver(receiverToExtract)) + val possibleTypes = dataFlowInfo.getCollectedTypes(DataFlowValueFactory.createDataFlowValueForStableReceiver(receiverToExtract)) if (possibleTypes.isNotEmpty()) CommonSupertypes.commonSupertype(possibleTypes) else null } else null typeByDataFlowInfo ?: receiverToExtract.type