Optimization: data flow info no more stores supertypes of the variable original type as possible types (dynamic is an exception)

This commit is contained in:
Mikhail Glukhikh
2015-11-30 17:36:12 +03:00
parent 9c73502bdc
commit 408dd9bc9d
2 changed files with 3 additions and 2 deletions
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts;
import com.google.common.collect.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
@@ -281,6 +281,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
public DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KotlinType type) {
if (value.getType().equals(type)) return this;
if (getPossibleTypes(value).contains(type)) return this;
if (!FlexibleTypesKt.isFlexible(value.getType()) && TypeUtilsKt.isSubtypeOf(value.getType(), type)) return this;
ImmutableMap<DataFlowValue, Nullability> newNullabilityInfo =
type.isMarkedNullable() ? EMPTY_NULLABILITY_INFO : ImmutableMap.of(value, NOT_NULL);
SetMultimap<DataFlowValue, KotlinType> newTypeInfo = ImmutableSetMultimap.of(value, type);
+1 -1
View File
@@ -19,6 +19,6 @@ import foo.View
fun String.gah(view:View ?) {
if (view is <!UNRESOLVED_REFERENCE!>TextView<!>)
<!DEBUG_INFO_SMARTCAST!>view<!>
view
else <!UNRESOLVED_REFERENCE!>TextView<!>() as foo.TextView
}