Kapt3: Kapt3 fails on several top-level functions in one package (KT-14991)
This commit is contained in:
committed by
Yan Zhulanow
parent
34316d09bf
commit
6217d21c24
+10
-6
@@ -23,10 +23,7 @@ import com.sun.tools.javac.tree.JCTree
|
||||
import com.sun.tools.javac.tree.JCTree.*
|
||||
import com.sun.tools.javac.tree.TreeMaker
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.kapt3.*
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptTreeMaker
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject
|
||||
@@ -151,7 +148,14 @@ class ClassFileToSourceStubConverter(
|
||||
return null
|
||||
}
|
||||
|
||||
val simpleName = treeMaker.name(if (isDefaultImpls) "DefaultImpls" else descriptor.name.asString())
|
||||
val simpleName = when (descriptor) {
|
||||
is PackageFragmentDescriptor -> {
|
||||
val className = clazz.name.drop(packageFqName.length + 1)
|
||||
if (className.isEmpty()) throw IllegalStateException("Invalid package facade class name: ${clazz.name}")
|
||||
className
|
||||
}
|
||||
else -> if (isDefaultImpls) "DefaultImpls" else descriptor.name.asString()
|
||||
}
|
||||
|
||||
val interfaces = mapJList(clazz.interfaces) {
|
||||
if (isAnnotation && it == "java/lang/annotation/Annotation") return@mapJList null
|
||||
@@ -180,7 +184,7 @@ class ClassFileToSourceStubConverter(
|
||||
|
||||
return treeMaker.ClassDef(
|
||||
modifiers,
|
||||
simpleName,
|
||||
treeMaker.name(simpleName),
|
||||
genericType.typeParameters,
|
||||
if (hasSuperClass) genericType.superClass else null,
|
||||
genericType.interfaces,
|
||||
|
||||
+18
@@ -72,6 +72,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fileFacadeJvmName.kt")
|
||||
public void testFileFacadeJvmName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/fileFacadeJvmName.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("functions.kt")
|
||||
public void testFunctions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/functions.kt");
|
||||
@@ -114,6 +120,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multifileClass.kt")
|
||||
public void testMultifileClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/multifileClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/nestedClasses.kt");
|
||||
@@ -132,6 +144,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("severalPackageParts.kt")
|
||||
public void testSeveralPackageParts() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/severalPackageParts.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("strangeNames.kt")
|
||||
public void testStrangeNames() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/strangeNames.kt");
|
||||
|
||||
+2
-2
@@ -60,9 +60,9 @@ public enum Enum {
|
||||
|
||||
package test;
|
||||
|
||||
public final class test {
|
||||
public final class AnnotationsTest {
|
||||
|
||||
public test() {
|
||||
public AnnotationsTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
@file:JvmName("FacadeName")
|
||||
package a.b.c
|
||||
|
||||
fun foo() {}
|
||||
|
||||
val bar = 3
|
||||
@@ -0,0 +1,16 @@
|
||||
package a.b.c;
|
||||
|
||||
public final class FacadeName {
|
||||
|
||||
public FacadeName() {
|
||||
super();
|
||||
}
|
||||
private static final int bar = 3;
|
||||
|
||||
public static final void foo() {
|
||||
}
|
||||
|
||||
public static final int getBar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
// FILE: a.kt
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("M1")
|
||||
package test
|
||||
|
||||
fun foo() {}
|
||||
|
||||
// FILE: b.kt
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("M1")
|
||||
package test
|
||||
|
||||
fun bar() {}
|
||||
|
||||
// FILE: c.kt
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("M2")
|
||||
package test
|
||||
|
||||
fun baz() {}
|
||||
@@ -0,0 +1,28 @@
|
||||
package test;
|
||||
|
||||
public final class M1 {
|
||||
|
||||
public M1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static final void bar() {
|
||||
}
|
||||
|
||||
public static final void foo() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package test;
|
||||
|
||||
public final class M2 {
|
||||
|
||||
public M2() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static final void baz() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// FILE: a.kt
|
||||
package test
|
||||
|
||||
fun foo() {}
|
||||
|
||||
// FILE: b.kt
|
||||
package test
|
||||
|
||||
fun bar() {}
|
||||
@@ -0,0 +1,25 @@
|
||||
package test;
|
||||
|
||||
public final class AKt {
|
||||
|
||||
public AKt() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static final void foo() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package test;
|
||||
|
||||
public final class BKt {
|
||||
|
||||
public BKt() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static final void bar() {
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -9,9 +9,9 @@ public abstract @interface Anno {
|
||||
|
||||
package test.another;
|
||||
|
||||
public final class another {
|
||||
public final class TopLevelKt {
|
||||
|
||||
public another() {
|
||||
public TopLevelKt() {
|
||||
super();
|
||||
}
|
||||
private static final int topLevelProperty = 2;
|
||||
|
||||
Reference in New Issue
Block a user