Fix maven build
Do not create class objects for classes which come from Java.
This commit is contained in:
+10
-3
@@ -114,8 +114,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.staticMembers = staticMembers;
|
this.staticMembers = staticMembers;
|
||||||
this.kotlin = psiClass != null &&
|
this.kotlin = psiClass != null && isKotlinClass(psiClass);
|
||||||
(new PsiClassWrapper(psiClass).getJetClass().isDefined() || psiClass.getName().equals(JvmAbi.PACKAGE_CLASS));
|
|
||||||
classOrNamespaceDescriptor = descriptor;
|
classOrNamespaceDescriptor = descriptor;
|
||||||
|
|
||||||
if (fqName != null && fqName.lastSegmentIs(Name.identifier(JvmAbi.PACKAGE_CLASS)) && psiClass != null && kotlin) {
|
if (fqName != null && fqName.lastSegmentIs(Name.identifier(JvmAbi.PACKAGE_CLASS)) && psiClass != null && kotlin) {
|
||||||
@@ -586,6 +585,10 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
return createClassObjectDescriptorForEnum(containing, psiClass);
|
return createClassObjectDescriptorForEnum(containing, psiClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isKotlinClass(psiClass)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// If there's at least one inner enum, we need to create a class object (to put this enum into)
|
// If there's at least one inner enum, we need to create a class object (to put this enum into)
|
||||||
for (PsiClass innerClass : psiClass.getInnerClasses()) {
|
for (PsiClass innerClass : psiClass.getInnerClasses()) {
|
||||||
if (isInnerEnum(innerClass, containing)) {
|
if (isInnerEnum(innerClass, containing)) {
|
||||||
@@ -610,6 +613,10 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
return classObjectDescriptor;
|
return classObjectDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isKotlinClass(@NotNull PsiClass psiClass) {
|
||||||
|
return new PsiClassWrapper(psiClass).getJetClass().isDefined() || psiClass.getName().equals(JvmAbi.PACKAGE_CLASS);
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isInnerEnum(@NotNull PsiClass innerClass, DeclarationDescriptor owner) {
|
private static boolean isInnerEnum(@NotNull PsiClass innerClass, DeclarationDescriptor owner) {
|
||||||
if (!innerClass.isEnum()) return false;
|
if (!innerClass.isEnum()) return false;
|
||||||
if (!(owner instanceof ClassDescriptor)) return false;
|
if (!(owner instanceof ClassDescriptor)) return false;
|
||||||
@@ -679,7 +686,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
if (clazz == null) {
|
if (clazz == null) {
|
||||||
throw new IllegalStateException("PsiClass not found by name " + containerFqName + ", required to be container declaration of " + fqName);
|
throw new IllegalStateException("PsiClass not found by name " + containerFqName + ", required to be container declaration of " + fqName);
|
||||||
}
|
}
|
||||||
if (isInnerEnum(psiClass, clazz)) {
|
if (isInnerEnum(psiClass, clazz) && isKotlinClass(psiClass)) {
|
||||||
ClassDescriptor classObjectDescriptor = clazz.getClassObjectDescriptor();
|
ClassDescriptor classObjectDescriptor = clazz.getClassObjectDescriptor();
|
||||||
if (classObjectDescriptor == null) {
|
if (classObjectDescriptor == null) {
|
||||||
throw new IllegalStateException("Class object for a class with inner enum should've been created earlier: " + clazz);
|
throw new IllegalStateException("Class object for a class with inner enum should've been created earlier: " + clazz);
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
public class noClassObjectForJavaClass {
|
||||||
|
public enum E { ENTRY }
|
||||||
|
|
||||||
|
public static String foo() { return "OK"; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return noClassObjectForJavaClass.foo()!!
|
||||||
|
}
|
||||||
@@ -381,4 +381,8 @@ public class StdlibTest extends CodegenTestCase {
|
|||||||
public void testCollections() {
|
public void testCollections() {
|
||||||
blackBoxFile("jdk-annotations/collections.kt");
|
blackBoxFile("jdk-annotations/collections.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNoClassObjectForJavaClass() throws Exception {
|
||||||
|
blackBoxFileWithJava("stdlib/noClassObjectForJavaClass.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user