KT-11952 J2K: Assertion failed in PropertyDetectionCache.get on conversion of access to Java constant of anonymous type
#KT-11952 Fixed
This commit is contained in:
@@ -451,6 +451,8 @@ class Converter private constructor(
|
||||
}
|
||||
|
||||
fun shouldDeclareVariableType(variable: PsiVariable, type: Type, canChangeType: Boolean): Boolean {
|
||||
assert(inConversionScope(variable))
|
||||
|
||||
val initializer = variable.initializer
|
||||
if (initializer == null || initializer.isNullLiteral()) return true
|
||||
if (initializer.type is PsiPrimitiveType && type is PrimitiveType) {
|
||||
|
||||
@@ -535,6 +535,8 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
fun isNullable(target: PsiVariable): Boolean {
|
||||
if (typeConverter.variableNullability(target).isNullable(codeConverter.settings)) return true
|
||||
|
||||
if (!converter.inConversionScope(target)) return false
|
||||
|
||||
val canChangeType = when (target) {
|
||||
is PsiLocalVariable -> codeConverter.canChangeType(target)
|
||||
is PsiField -> target.hasModifierProperty(PsiModifier.PRIVATE)
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.Bar;
|
||||
|
||||
public class Foo {
|
||||
public static void foo() {
|
||||
Object o = Bar.SET;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.Bar
|
||||
|
||||
object Foo {
|
||||
fun foo() {
|
||||
val o = Bar.SET
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Bar {
|
||||
Set<String> SET = new HashSet<String>() { };
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Bar {
|
||||
Set<String> SET = new HashSet<String>() { };
|
||||
}
|
||||
@@ -47,6 +47,12 @@ public class JavaToKotlinConverterMultiFileTestGenerated extends AbstractJavaToK
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KT11952")
|
||||
public void testKT11952() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/multiFile/KT11952/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ProtectedVisibility")
|
||||
public void testProtectedVisibility() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/multiFile/ProtectedVisibility/");
|
||||
|
||||
Reference in New Issue
Block a user