DataFlowInfo converted to Kotlin, DataFlowInfoFactory introduced
This commit is contained in:
@@ -61,7 +61,7 @@ import org.jetbrains.kotlin.parsing.KotlinParserDefinition;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtScript;
|
||||
import org.jetbrains.kotlin.resolve.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
|
||||
import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||
@@ -160,7 +160,7 @@ public class ReplInterpreter {
|
||||
new JvmPackagePartProvider(environment)
|
||||
);
|
||||
|
||||
this.topDownAnalysisContext = new TopDownAnalysisContext(TopDownAnalysisMode.LocalDeclarations, DataFlowInfo.EMPTY,
|
||||
this.topDownAnalysisContext = new TopDownAnalysisContext(TopDownAnalysisMode.LocalDeclarations, DataFlowInfoFactory.EMPTY,
|
||||
container.getResolveSession().getDeclarationScopeProvider());
|
||||
this.topDownAnalyzer = container.getLazyTopDownAnalyzerForTopLevel();
|
||||
this.resolveSession = container.getResolveSession();
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.CallResolver;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
|
||||
@@ -33,7 +33,6 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
@@ -191,7 +190,7 @@ public class AnnotationResolver {
|
||||
trace, scope,
|
||||
CallMaker.makeCall(null, null, annotationEntry),
|
||||
NO_EXPECTED_TYPE,
|
||||
DataFlowInfo.EMPTY,
|
||||
DataFlowInfoFactory.EMPTY,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
@@ -170,7 +170,7 @@ public class BindingContextUtils {
|
||||
if (!context.get(BindingContext.PROCESSED, expression)) return null;
|
||||
// NB: should never return null if expression is already processed
|
||||
KotlinTypeInfo result = context.get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
return result != null ? result : TypeInfoFactoryKt.noTypeInfo(DataFlowInfo.EMPTY);
|
||||
return result != null ? result : TypeInfoFactoryKt.noTypeInfo(DataFlowInfoFactory.EMPTY);
|
||||
}
|
||||
|
||||
public static boolean isExpressionWithValidReference(
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeVariableKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.scopes.ScopeUtils;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
@@ -141,7 +142,7 @@ public class DelegatedPropertyResolver {
|
||||
TemporaryBindingTrace traceToResolvePDMethod = TemporaryBindingTrace.create(trace, "Trace to resolve propertyDelegated method in delegated property");
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
traceToResolvePDMethod, delegateFunctionsScope,
|
||||
DataFlowInfo.EMPTY, TypeUtils.NO_EXPECTED_TYPE);
|
||||
DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE);
|
||||
|
||||
KtPsiFactory psiFactory = KtPsiFactory(delegateExpression);
|
||||
List<KtExpression> arguments = Collections.singletonList(createExpressionForProperty(psiFactory));
|
||||
@@ -242,7 +243,7 @@ public class DelegatedPropertyResolver {
|
||||
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
trace, delegateFunctionsScope,
|
||||
DataFlowInfo.EMPTY, expectedType);
|
||||
DataFlowInfoFactory.EMPTY, expectedType);
|
||||
|
||||
boolean hasThis = propertyDescriptor.getExtensionReceiverParameter() != null || propertyDescriptor.getDispatchReceiverParameter() != null;
|
||||
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtScript;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ImportResolver;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class LazyTopDownAnalyzerForTopLevel {
|
||||
@NotNull TopDownAnalysisMode topDownAnalysisMode,
|
||||
@NotNull Collection<? extends PsiElement> elements
|
||||
) {
|
||||
TopDownAnalysisContext c = lazyTopDownAnalyzer.analyzeDeclarations(topDownAnalysisMode, elements, DataFlowInfo.EMPTY);
|
||||
TopDownAnalysisContext c = lazyTopDownAnalyzer.analyzeDeclarations(topDownAnalysisMode, elements, DataFlowInfoFactory.EMPTY);
|
||||
|
||||
resolveImportsInAllFiles(c, codeAnalyzer);
|
||||
|
||||
|
||||
+29
-36
@@ -14,41 +14,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.smartcasts;
|
||||
package org.jetbrains.kotlin.resolve.calls.smartcasts
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.google.common.collect.ImmutableMap
|
||||
import com.google.common.collect.SetMultimap
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
/**
|
||||
* This interface is intended to provide and edit information about value nullabilities and possible types.
|
||||
* Data flow info is immutable so functions never change it.
|
||||
*/
|
||||
public interface DataFlowInfo {
|
||||
DataFlowInfo EMPTY = new DelegatingDataFlowInfo(null, ImmutableMap.<DataFlowValue, Nullability>of(), DelegatingDataFlowInfo.newTypeInfo());
|
||||
interface DataFlowInfo {
|
||||
|
||||
@NotNull
|
||||
Map<DataFlowValue, Nullability> getCompleteNullabilityInfo();
|
||||
val completeNullabilityInfo: Map<DataFlowValue, Nullability>
|
||||
|
||||
@NotNull
|
||||
SetMultimap<DataFlowValue, KotlinType> getCompleteTypeInfo();
|
||||
val completeTypeInfo: SetMultimap<DataFlowValue, KotlinType>
|
||||
|
||||
/**
|
||||
* Returns collected nullability for the given value, NOT taking its predictability into account.
|
||||
*/
|
||||
@NotNull
|
||||
Nullability getCollectedNullability(@NotNull DataFlowValue key);
|
||||
fun getCollectedNullability(key: DataFlowValue): Nullability
|
||||
|
||||
/**
|
||||
* Returns collected nullability for the given value if it's predictable.
|
||||
* Otherwise basic value nullability is returned
|
||||
*/
|
||||
@NotNull
|
||||
Nullability getPredictableNullability(@NotNull DataFlowValue key);
|
||||
fun getPredictableNullability(key: DataFlowValue): Nullability
|
||||
|
||||
/**
|
||||
* Returns possible types for the given value, NOT taking its predictability into account.
|
||||
@@ -56,8 +47,7 @@ public interface DataFlowInfo {
|
||||
* IMPORTANT: by default, the original (native) type for this value
|
||||
* are NOT included. So it's quite possible to get an empty set here.
|
||||
*/
|
||||
@NotNull
|
||||
Set<KotlinType> getCollectedTypes(@NotNull DataFlowValue key);
|
||||
fun getCollectedTypes(key: DataFlowValue): Set<KotlinType>
|
||||
|
||||
/**
|
||||
* Returns possible types for the given value if it's predictable.
|
||||
@@ -66,46 +56,49 @@ public interface DataFlowInfo {
|
||||
* IMPORTANT: by default, the original (native) type for this value
|
||||
* are NOT included. So it's quite possible to get an empty set here.
|
||||
*/
|
||||
@NotNull
|
||||
Set<KotlinType> getPredictableTypes(@NotNull DataFlowValue key);
|
||||
fun getPredictableTypes(key: DataFlowValue): Set<KotlinType>
|
||||
|
||||
/**
|
||||
* Call this function to clear all data flow information about
|
||||
* the given data flow value. Useful when we are not sure how this value can be changed, e.g. in a loop.
|
||||
*/
|
||||
@NotNull
|
||||
DataFlowInfo clearValueInfo(@NotNull DataFlowValue value);
|
||||
fun clearValueInfo(value: DataFlowValue): DataFlowInfo
|
||||
|
||||
/**
|
||||
* Call this function when b is assigned to a
|
||||
*/
|
||||
@NotNull
|
||||
DataFlowInfo assign(@NotNull DataFlowValue a, @NotNull DataFlowValue b);
|
||||
fun assign(a: DataFlowValue, b: DataFlowValue): DataFlowInfo
|
||||
|
||||
/**
|
||||
* Call this function when it's known than a == b
|
||||
*/
|
||||
@NotNull
|
||||
DataFlowInfo equate(@NotNull DataFlowValue a, @NotNull DataFlowValue b);
|
||||
fun equate(a: DataFlowValue, b: DataFlowValue): DataFlowInfo
|
||||
|
||||
/**
|
||||
* Call this function when it's known than a != b
|
||||
*/
|
||||
@NotNull
|
||||
DataFlowInfo disequate(@NotNull DataFlowValue a, @NotNull DataFlowValue b);
|
||||
fun disequate(a: DataFlowValue, b: DataFlowValue): DataFlowInfo
|
||||
|
||||
@NotNull
|
||||
DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KotlinType type);
|
||||
fun establishSubtyping(value: DataFlowValue, type: KotlinType): DataFlowInfo
|
||||
|
||||
/**
|
||||
* Call this function to add data flow information from other to this and return sum as the result
|
||||
*/
|
||||
@NotNull
|
||||
DataFlowInfo and(@NotNull DataFlowInfo other);
|
||||
fun and(other: DataFlowInfo): DataFlowInfo
|
||||
|
||||
/**
|
||||
* Call this function to choose data flow information common for this and other and return it as the result
|
||||
*/
|
||||
@NotNull
|
||||
DataFlowInfo or(@NotNull DataFlowInfo other);
|
||||
fun or(other: DataFlowInfo): DataFlowInfo
|
||||
|
||||
companion object {
|
||||
val EMPTY = DataFlowInfoFactory.EMPTY
|
||||
}
|
||||
}
|
||||
|
||||
object DataFlowInfoFactory {
|
||||
@JvmField
|
||||
val EMPTY: DataFlowInfo = DelegatingDataFlowInfo(
|
||||
null, ImmutableMap.of<DataFlowValue, Nullability>(), DelegatingDataFlowInfo.newTypeInfo()
|
||||
)
|
||||
}
|
||||
|
||||
+34
-35
@@ -27,7 +27,7 @@ import java.util.*
|
||||
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
|
||||
internal class DelegatingDataFlowInfo @JvmOverloads constructor(
|
||||
internal class DelegatingDataFlowInfo(
|
||||
private val parent: DataFlowInfo?,
|
||||
private val nullabilityInfo: ImmutableMap<DataFlowValue, Nullability>,
|
||||
// Also immutable
|
||||
@@ -39,35 +39,37 @@ internal class DelegatingDataFlowInfo @JvmOverloads constructor(
|
||||
private val valueWithGivenTypeInfo: DataFlowValue? = null
|
||||
) : DataFlowInfo {
|
||||
|
||||
override fun getCompleteNullabilityInfo(): Map<DataFlowValue, Nullability> {
|
||||
val result = Maps.newHashMap<DataFlowValue, Nullability>()
|
||||
var info: DelegatingDataFlowInfo? = this
|
||||
while (info != null) {
|
||||
for ((key, value) in info.nullabilityInfo) {
|
||||
if (!result.containsKey(key)) {
|
||||
result.put(key, value)
|
||||
override val completeNullabilityInfo: Map<DataFlowValue, Nullability>
|
||||
get() {
|
||||
val result = Maps.newHashMap<DataFlowValue, Nullability>()
|
||||
var info: DelegatingDataFlowInfo? = this
|
||||
while (info != null) {
|
||||
for ((key, value) in info.nullabilityInfo) {
|
||||
if (!result.containsKey(key)) {
|
||||
result.put(key, value)
|
||||
}
|
||||
}
|
||||
info = info.parent as DelegatingDataFlowInfo?
|
||||
}
|
||||
info = info.parent as DelegatingDataFlowInfo?
|
||||
return result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getCompleteTypeInfo(): SetMultimap<DataFlowValue, KotlinType> {
|
||||
val result = newTypeInfo()
|
||||
val withGivenTypeInfo = HashSet<DataFlowValue>()
|
||||
var info: DelegatingDataFlowInfo? = this
|
||||
while (info != null) {
|
||||
for (key in info.typeInfo.keySet()) {
|
||||
if (!withGivenTypeInfo.contains(key)) {
|
||||
result.putAll(key, info.typeInfo.get(key))
|
||||
override val completeTypeInfo: SetMultimap<DataFlowValue, KotlinType>
|
||||
get() {
|
||||
val result = newTypeInfo()
|
||||
val withGivenTypeInfo = HashSet<DataFlowValue>()
|
||||
var info: DelegatingDataFlowInfo? = this
|
||||
while (info != null) {
|
||||
for (key in info.typeInfo.keySet()) {
|
||||
if (!withGivenTypeInfo.contains(key)) {
|
||||
result.putAll(key, info.typeInfo.get(key))
|
||||
}
|
||||
}
|
||||
info.valueWithGivenTypeInfo?.let { withGivenTypeInfo.add(it) }
|
||||
info = info.parent as DelegatingDataFlowInfo?
|
||||
}
|
||||
info.valueWithGivenTypeInfo?.let { withGivenTypeInfo.add(it) }
|
||||
info = info.parent as DelegatingDataFlowInfo?
|
||||
return result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getCollectedNullability(key: DataFlowValue) = getNullability(key, false)
|
||||
|
||||
@@ -226,13 +228,12 @@ internal class DelegatingDataFlowInfo @JvmOverloads constructor(
|
||||
return DelegatingDataFlowInfo(this, newNullabilityInfo, newTypeInfo)
|
||||
}
|
||||
|
||||
override fun and(otherInfo: DataFlowInfo): DataFlowInfo {
|
||||
if (otherInfo === DataFlowInfo.EMPTY) return this
|
||||
if (this === DataFlowInfo.EMPTY) return otherInfo
|
||||
if (this === otherInfo) return this
|
||||
override fun and(other: DataFlowInfo): DataFlowInfo {
|
||||
if (other === DataFlowInfo.EMPTY) return this
|
||||
if (this === DataFlowInfo.EMPTY) return other
|
||||
if (this === other) return this
|
||||
|
||||
assert(otherInfo is DelegatingDataFlowInfo) { "Unknown DataFlowInfo type: " + otherInfo }
|
||||
val other = otherInfo as DelegatingDataFlowInfo
|
||||
assert(other is DelegatingDataFlowInfo) { "Unknown DataFlowInfo type: " + other }
|
||||
|
||||
val nullabilityMapBuilder = Maps.newHashMap<DataFlowValue, Nullability>()
|
||||
for ((key, otherFlags) in other.completeNullabilityInfo) {
|
||||
@@ -259,13 +260,12 @@ internal class DelegatingDataFlowInfo @JvmOverloads constructor(
|
||||
else if (this.containsNothing()) other
|
||||
else Sets.intersection(this, other)
|
||||
|
||||
override fun or(otherInfo: DataFlowInfo): DataFlowInfo {
|
||||
if (otherInfo === DataFlowInfo.EMPTY) return DataFlowInfo.EMPTY
|
||||
override fun or(other: DataFlowInfo): DataFlowInfo {
|
||||
if (other === DataFlowInfo.EMPTY) return DataFlowInfo.EMPTY
|
||||
if (this === DataFlowInfo.EMPTY) return DataFlowInfo.EMPTY
|
||||
if (this === otherInfo) return this
|
||||
if (this === other) return this
|
||||
|
||||
assert(otherInfo is DelegatingDataFlowInfo) { "Unknown DataFlowInfo type: " + otherInfo }
|
||||
val other = otherInfo as DelegatingDataFlowInfo
|
||||
assert(other is DelegatingDataFlowInfo) { "Unknown DataFlowInfo type: " + other }
|
||||
|
||||
val nullabilityMapBuilder = Maps.newHashMap<DataFlowValue, Nullability>()
|
||||
for ((key, otherFlags) in other.completeNullabilityInfo) {
|
||||
@@ -297,7 +297,6 @@ internal class DelegatingDataFlowInfo @JvmOverloads constructor(
|
||||
private fun containsAll(first: SetMultimap<DataFlowValue, KotlinType>, second: SetMultimap<DataFlowValue, KotlinType>) =
|
||||
first.entries().containsAll(second.entries())
|
||||
|
||||
@JvmStatic
|
||||
fun newTypeInfo(): SetMultimap<DataFlowValue, KotlinType> = LinkedHashMultimap.create<DataFlowValue, KotlinType>()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyScriptDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
@@ -91,6 +92,6 @@ public class DeclarationScopeProviderImpl implements DeclarationScopeProvider {
|
||||
@NotNull
|
||||
@Override
|
||||
public DataFlowInfo getOuterDataFlowInfoForDeclaration(@NotNull PsiElement elementOfDeclaration) {
|
||||
return DataFlowInfo.EMPTY;
|
||||
return DataFlowInfoFactory.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
|
||||
@@ -143,7 +143,7 @@ public class ExpectedResolveDataUtil {
|
||||
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
new BindingTraceContext(), lexicalScope,
|
||||
DataFlowInfo.EMPTY, TypeUtils.NO_EXPECTED_TYPE);
|
||||
DataFlowInfoFactory.EMPTY, TypeUtils.NO_EXPECTED_TYPE);
|
||||
|
||||
OverloadResolutionResults<FunctionDescriptor> functions = container.getFakeCallResolver().resolveFakeCall(
|
||||
context, null, Name.identifier(name), null, parameterTypes);
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
||||
@@ -132,7 +132,7 @@ public class DefaultModalityModifiersTest extends KotlinLiteFixture {
|
||||
KtNamedFunction function = (KtNamedFunction) declarations.get(0);
|
||||
SimpleFunctionDescriptor functionDescriptor =
|
||||
functionDescriptorResolver.resolveFunctionDescriptor(classDescriptor, scope, function,
|
||||
KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
|
||||
|
||||
assertEquals(expectedFunctionModality, functionDescriptor.getModality());
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class DefaultModalityModifiersTest extends KotlinLiteFixture {
|
||||
List<KtDeclaration> declarations = aClass.getDeclarations();
|
||||
KtProperty property = (KtProperty) declarations.get(0);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(
|
||||
classDescriptor, scope, property, KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
classDescriptor, scope, property, KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
|
||||
|
||||
assertEquals(expectedPropertyModality, propertyDescriptor.getModality());
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class DefaultModalityModifiersTest extends KotlinLiteFixture {
|
||||
List<KtDeclaration> declarations = aClass.getDeclarations();
|
||||
KtProperty property = (KtProperty) declarations.get(0);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(
|
||||
classDescriptor, scope, property, KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
classDescriptor, scope, property, KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
|
||||
PropertyAccessorDescriptor propertyAccessor = isGetter
|
||||
? propertyDescriptor.getGetter()
|
||||
: propertyDescriptor.getSetter();
|
||||
|
||||
@@ -24,10 +24,9 @@ import org.jetbrains.kotlin.psi.KtNamedFunction;
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||
import org.jetbrains.kotlin.resolve.FunctionDescriptorResolver;
|
||||
import org.jetbrains.kotlin.resolve.OverloadUtil;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
@@ -173,6 +172,6 @@ public class KotlinOverloadTest extends KotlinLiteFixture {
|
||||
private FunctionDescriptor makeFunction(String funDecl) {
|
||||
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
|
||||
LexicalScope scope = TypeTestUtilsKt.builtInPackageAsLexicalScope(JvmPlatform.INSTANCE.getBuiltIns());
|
||||
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function, KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function, KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction;
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||
import org.jetbrains.kotlin.resolve.FunctionDescriptorResolver;
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
||||
@@ -168,6 +168,6 @@ public class KotlinOverridingTest extends KotlinLiteFixture {
|
||||
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
|
||||
LexicalScope scope = TypeTestUtilsKt.builtInPackageAsLexicalScope(root.getBuiltIns());
|
||||
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function,
|
||||
KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.BindingTraceContext;
|
||||
import org.jetbrains.kotlin.resolve.TypeResolver;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
||||
@@ -544,14 +544,14 @@ public class KotlinTypeCheckerTest extends KotlinLiteFixture {
|
||||
private void assertType(String expression, KotlinType expectedType) {
|
||||
Project project = getProject();
|
||||
KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression);
|
||||
KotlinType type = expressionTypingServices.getType(scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
||||
KotlinType type = expressionTypingServices.getType(scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
||||
assertTrue(type + " != " + expectedType, type.equals(expectedType));
|
||||
}
|
||||
|
||||
private void assertErrorType(String expression) {
|
||||
Project project = getProject();
|
||||
KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression);
|
||||
KotlinType type = expressionTypingServices.safeGetType(scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
||||
KotlinType type = expressionTypingServices.safeGetType(scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
||||
assertTrue("Error type expected but " + type + " returned", type.isError());
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ public class KotlinTypeCheckerTest extends KotlinLiteFixture {
|
||||
private void assertType(LexicalScope scope, String expression, String expectedTypeStr) {
|
||||
Project project = getProject();
|
||||
KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression);
|
||||
KotlinType type = expressionTypingServices.getType(scope, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, new BindingTraceContext());
|
||||
KotlinType type = expressionTypingServices.getType(scope, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, new BindingTraceContext());
|
||||
KotlinType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr);
|
||||
assertEquals(expectedType, type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user