[NI] Don't loose inference session during property resolve
#KT-31620 Fixed
This commit is contained in:
+5
@@ -1867,6 +1867,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inferenceFromMethodInsideLocalVariable.kt")
|
||||
public void testInferenceFromMethodInsideLocalVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferenceFromMethodInsideLocalVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt15516.kt")
|
||||
public void testKt15516() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -1867,6 +1867,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inferenceFromMethodInsideLocalVariable.kt")
|
||||
public void testInferenceFromMethodInsideLocalVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferenceFromMethodInsideLocalVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt15516.kt")
|
||||
public void testKt15516() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt");
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorResolver;
|
||||
import org.jetbrains.kotlin.resolve.FunctionDescriptorResolver;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||
@@ -138,7 +139,10 @@ public class DefaultModalityModifiersTest extends KotlinTestWithEnvironment {
|
||||
List<KtDeclaration> declarations = aClass.getDeclarations();
|
||||
KtProperty property = (KtProperty) declarations.get(0);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(
|
||||
classDescriptor, scope, scope, property, KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
|
||||
classDescriptor, scope, scope, property,
|
||||
KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY,
|
||||
InferenceSession.Companion.getDefault()
|
||||
);
|
||||
|
||||
assertEquals(expectedPropertyModality, propertyDescriptor.getModality());
|
||||
}
|
||||
@@ -151,7 +155,10 @@ public class DefaultModalityModifiersTest extends KotlinTestWithEnvironment {
|
||||
List<KtDeclaration> declarations = aClass.getDeclarations();
|
||||
KtProperty property = (KtProperty) declarations.get(0);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(
|
||||
classDescriptor, scope, scope, property, KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
|
||||
classDescriptor, scope, scope, property,
|
||||
KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY,
|
||||
InferenceSession.Companion.getDefault()
|
||||
);
|
||||
PropertyAccessorDescriptor propertyAccessor = isGetter
|
||||
? propertyDescriptor.getGetter()
|
||||
: propertyDescriptor.getSetter();
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTraceContext;
|
||||
import org.jetbrains.kotlin.resolve.TypeResolver;
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
@@ -530,7 +531,11 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
||||
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, DataFlowInfoFactory.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
||||
KotlinType type = expressionTypingServices.getType(
|
||||
scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE,
|
||||
DataFlowInfoFactory.EMPTY, InferenceSession.Companion.getDefault(),
|
||||
KotlinTestUtils.DUMMY_TRACE
|
||||
);
|
||||
assertNotNull(type);
|
||||
assertEquals(type + " != " + expectedType, expectedType, type);
|
||||
}
|
||||
@@ -556,7 +561,11 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
||||
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, DataFlowInfoFactory.EMPTY, new BindingTraceContext());
|
||||
KotlinType type = expressionTypingServices.getType(
|
||||
scope, ktExpression, TypeUtils.NO_EXPECTED_TYPE,
|
||||
DataFlowInfoFactory.EMPTY, InferenceSession.Companion.getDefault(),
|
||||
new BindingTraceContext()
|
||||
);
|
||||
KotlinType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr);
|
||||
assertEquals(expectedType, type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user