Do not produce error classes for not found annotations
This commit is contained in:
@@ -48,7 +48,7 @@ class MethodBinding(val method: Method, val argumentDescriptors: List<ValueDescr
|
||||
fun computeArguments(argumentDescriptors: List<ValueDescriptor>): List<Any> = argumentDescriptors.map { it.getValue() }
|
||||
|
||||
fun Class<*>.bindToConstructor(context: ValueResolveContext): ConstructorBinding {
|
||||
val constructorInfo = getInfo().constructorInfo!!
|
||||
val constructorInfo = getInfo().constructorInfo ?: error("No constructor for $this: ${getInfo()}")
|
||||
val candidate = constructorInfo.constructor
|
||||
return ConstructorBinding(candidate, candidate.bindArguments(constructorInfo.parameters, context))
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
public interface A {
|
||||
@interface Anno {
|
||||
String value();
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
@A.Anno("B")
|
||||
public interface B {
|
||||
@A.Anno("foo")
|
||||
<T> T foo(T t);
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyJavaNestedAnnotation/source.kt
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
package c
|
||||
|
||||
import test.B
|
||||
|
||||
// There should be _no_ error despite the fact that B and B#foo are annotated with an annotation which cannot be resolved
|
||||
fun bar(b: B) {
|
||||
b.foo("")
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package a
|
||||
|
||||
interface A {
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE_PARAMETER)
|
||||
annotation class Anno(val value: String)
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
package b
|
||||
|
||||
import a.A
|
||||
|
||||
@A.Anno("B")
|
||||
interface B {
|
||||
@A.Anno("foo")
|
||||
fun <@A.Anno("T") T> foo(t: T) = t
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
package c
|
||||
|
||||
import b.B
|
||||
|
||||
// There should be _no_ error despite the fact that B and B#foo are annotated with an annotation which cannot be resolved
|
||||
fun bar(b: B) {
|
||||
b.foo("")
|
||||
}
|
||||
+11
-1
@@ -52,6 +52,7 @@ import org.jetbrains.org.objectweb.asm.ClassReader;
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.ClassWriter;
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@@ -83,7 +84,8 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
@NotNull
|
||||
private File compileLibrary(@NotNull String sourcePath, @NotNull File... extraClassPath) {
|
||||
File result = new File(tmpdir, sourcePath + ".jar");
|
||||
compileKotlin(sourcePath, result, extraClassPath);
|
||||
Pair<String, ExitCode> output = compileKotlin(sourcePath, result, extraClassPath);
|
||||
Assert.assertEquals(normalizeOutput(new Pair<String, ExitCode>("", ExitCode.OK)), normalizeOutput(output));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -298,6 +300,10 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
doTestBrokenKotlinLibrary("library", "a/A.class");
|
||||
}
|
||||
|
||||
public void testMissingDependencyNestedAnnotation() throws Exception {
|
||||
doTestBrokenKotlinLibrary("library", "a/A$Anno.class");
|
||||
}
|
||||
|
||||
public void testMissingDependencyConflictingLibraries() throws Exception {
|
||||
File library1 = copyJarFileWithoutEntry(compileLibrary("library1"),
|
||||
"a/A.class", "a/A$Inner.class", "a/AA.class", "a/AA$Inner.class");
|
||||
@@ -318,6 +324,10 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(output));
|
||||
}
|
||||
|
||||
public void testMissingDependencyJavaNestedAnnotation() throws Exception {
|
||||
doTestBrokenJavaLibrary("library", "test/A$Anno.class");
|
||||
}
|
||||
|
||||
/*test source mapping generation when source info is absent*/
|
||||
public void testInlineFunWithoutDebugInfo() throws Exception {
|
||||
compileKotlin("sourceInline.kt", tmpdir);
|
||||
|
||||
Reference in New Issue
Block a user