Fix "Descriptor of property not available in binding context" assert for declarations in bodies
This commit is contained in:
@@ -37,7 +37,6 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.caches.resolve.KotlinCacheManagerUtil;
|
||||
import org.jetbrains.jet.plugin.intentions.SpecifyTypeExplicitlyAction;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
@@ -128,7 +127,7 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
|
||||
|
||||
JetProperty property = QuickFixUtil.getParentElementOfType(diagnostic, JetProperty.class);
|
||||
if (property != null) {
|
||||
BindingContext context = KotlinCacheManagerUtil.getDeclarationsBindingContext(property);
|
||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) property.getContainingFile()).getBindingContext();
|
||||
JetType lowerBoundOfOverriddenPropertiesTypes = QuickFixUtil.findLowerBoundOfOverriddenCallablesReturnTypes(context, property);
|
||||
|
||||
PropertyDescriptor descriptor = (PropertyDescriptor) context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Change 'prop' type to 'Int'" "true"
|
||||
// ERROR: Null can not be a value of a non-null type Int
|
||||
trait Test<T> {
|
||||
val prop : T
|
||||
}
|
||||
|
||||
class Other {
|
||||
fun doTest() {
|
||||
val some = object: Test<Int> {
|
||||
override val prop: Int = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Change 'prop' type to 'Int'" "true"
|
||||
// ERROR: Null can not be a value of a non-null type Int
|
||||
trait Test<T> {
|
||||
val prop : T
|
||||
}
|
||||
|
||||
class Other {
|
||||
fun doTest() {
|
||||
val some = object: Test<Int> {
|
||||
override val <caret>prop = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1251,6 +1251,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest("idea/testData/quickfix/override/typeMismatchOnOverride/beforeChangeReturnTypeOfOverriddenFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("beforeObjectInsideBody.kt")
|
||||
public void testObjectInsideBody() throws Exception {
|
||||
doTest("idea/testData/quickfix/override/typeMismatchOnOverride/beforeObjectInsideBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("beforePropertyReturnTypeMismatchOnOverride.kt")
|
||||
public void testPropertyReturnTypeMismatchOnOverride() throws Exception {
|
||||
doTest("idea/testData/quickfix/override/typeMismatchOnOverride/beforePropertyReturnTypeMismatchOnOverride.kt");
|
||||
|
||||
Reference in New Issue
Block a user