DataFlowInfo converted to Kotlin, DataFlowInfoFactory introduced

This commit is contained in:
Mikhail Glukhikh
2016-01-19 15:08:47 +03:00
parent 9e1c2f396e
commit 7870ad2445
13 changed files with 90 additions and 98 deletions
@@ -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);
}