Generating annotations in correct order for methods with synthetic parameters.

#KT-4050 fixed
This commit is contained in:
Evgeny Gerashchenko
2013-10-08 00:18:03 +04:00
parent e401be7ee6
commit 9c38716829
7 changed files with 311 additions and 233 deletions
@@ -107,6 +107,16 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testAnnotationForParamInInstanceExtensionFunction() throws NoSuchFieldException, NoSuchMethodException {
loadText("class A() { fun String.x([Deprecated] i: Int) {}}");
Class<?> aClass = generateClass("A");
Method x = aClass.getMethod("x", String.class, int.class);
assertNotNull(x);
// Get annotations for first real parameter
Annotation[] annotations = x.getParameterAnnotations()[1];
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testParamInConstructor() throws NoSuchFieldException, NoSuchMethodException {
loadText("class A ([Deprecated] x: Int) {}");
Class<?> aClass = generateClass("A");
@@ -117,6 +127,27 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testParamInEnumConstructor() throws NoSuchFieldException, NoSuchMethodException {
loadText("enum class E([Deprecated] p: String)");
Class<?> klass = generateClass("E");
Constructor constructor = klass.getDeclaredConstructor(String.class, int.class, String.class);
assertNotNull(constructor);
// Get annotations for first parameter
Annotation[] annotations = constructor.getParameterAnnotations()[0];
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testParamInInnerConstructor() throws NoSuchFieldException, NoSuchMethodException {
loadText("class Outer { inner class Inner([Deprecated] x: Int) }");
Class<?> outer = generateClass("Outer");
Class<?> inner = outer.getDeclaredClasses()[0];
Constructor constructor = inner.getDeclaredConstructor(outer, int.class);
assertNotNull(constructor);
// Get annotations for first real parameter
Annotation[] annotations = constructor.getParameterAnnotations()[1];
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testPropFieldInConstructor() throws NoSuchFieldException, NoSuchMethodException {
loadText("class A ([Deprecated] var x: Int) {}");
Class<?> aClass = generateClass("A");
@@ -950,7 +950,7 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
public void testCopyToArray() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/toArray/copyToArray.kt");
}
@TestMetadata("kt3177-copyToArray.kt")
public void testKt3177_copyToArray() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/toArray/kt3177-copyToArray.kt");
@@ -78,6 +78,11 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg
doTest("compiler/testData/compileJavaAgainstKotlin/class/kt3561.kt");
}
@TestMetadata("kt4050.kt")
public void testKt4050() throws Exception {
doTest("compiler/testData/compileJavaAgainstKotlin/class/kt4050.kt");
}
@TestMetadata("Simple.kt")
public void testSimple() throws Exception {
doTest("compiler/testData/compileJavaAgainstKotlin/class/Simple.kt");