mark wrapper methods that pass default values of parameters as synthetic

#KT-7314 Fixed
This commit is contained in:
Dmitry Jemerov
2015-04-10 17:20:55 +02:00
parent 900a16a315
commit 9434e4bee9
11 changed files with 15 additions and 37 deletions
@@ -578,6 +578,7 @@ public class FunctionCodegen {
int flags = getVisibilityAccessFlag(functionDescriptor) |
getDeprecatedAccessFlag(functionDescriptor) |
ACC_SYNTHETIC |
(functionDescriptor instanceof ConstructorDescriptor ? 0 : ACC_STATIC);
Method defaultMethod = typeMapper.mapDefaultMethod(functionDescriptor, kind, owner);
@@ -2,8 +2,6 @@ public final class C {
@org.jetbrains.annotations.NotNull
public final java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String o, @org.jetbrains.annotations.NotNull java.lang.String s1, @org.jetbrains.annotations.NotNull java.lang.String k, @org.jetbrains.annotations.Nullable java.lang.String s2) { /* compiled code */ }
public static java.lang.String foo$default(C p, java.lang.String p1, java.lang.String p2, java.lang.String p3, java.lang.String p4, int p5) { /* compiled code */ }
@org.jetbrains.annotations.NotNull
public java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String p, @org.jetbrains.annotations.NotNull java.lang.String p1, @org.jetbrains.annotations.Nullable java.lang.String p2) { /* compiled code */ }
@@ -2,9 +2,6 @@ class WithoutPrimary {
public static A test1() {
return new A("123", "abc");
}
public static A test2() {
return new A(null, 1, 3, null);
}
public static A test3() {
return new A("123", 456);
}
@@ -14,9 +14,6 @@ fun box(): String {
val test1 = WithoutPrimary.test1().toString()
if (test1 != "123#abc") return "fail1: $test1"
val test2 = WithoutPrimary.test2().toString()
if (test2 != "def_x#1") return "fail2: $test2"
val test3 = WithoutPrimary.test3().toString()
if (test3 != "123#456") return "fail3: $test3"
@@ -0,0 +1,6 @@
class A(value: Int = 1)
fun box(): String {
val constructors = javaClass<A>().getConstructors().filter { !it.isSynthetic() }
return if (constructors.size() == 2) "OK" else constructors.size().toString()
}
@@ -1,8 +0,0 @@
package test;
class JavaClass {
public static void main(String[] args) {
TestPackage.foo$default(1, 0);
}
}
@@ -1,3 +0,0 @@
package test
fun foo(a: Int = 1) {}
@@ -7,28 +7,18 @@ class JavaClass {
}
catch (E1 e) {}
try {
new One(1, 0, null);
}
catch (E1 e) {}
try {
new One();
}
catch (E1 e) {}
try {
One.one$default(instance, 1, 1);
}
catch (E1 e) {}
try {
TestPackage.one(1);
}
catch (E1 e) {}
try {
TestPackage.one$default(1, 0);
TestPackage.one();
}
catch (E1 e) {}
}
@@ -2,7 +2,7 @@ package test
class E1: Exception()
throws(javaClass<E1>())
throws(javaClass<E1>()) overloads
fun one(a: Int = 1) {}
class One [throws(javaClass<E1>())] (a: Int = 1) {
@@ -1260,6 +1260,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/defaultArguments/constructor"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("checkIfConstructorIsSynthetic.kt")
public void testCheckIfConstructorIsSynthetic() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/defaultArguments/constructor/checkIfConstructorIsSynthetic.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("manyArgs.kt")
public void testManyArgs() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/defaultArguments/constructor/manyArgs.kt");
@@ -160,12 +160,6 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg
doTest(fileName);
}
@TestMetadata("DefaultMethod.kt")
public void testDefaultMethod() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/method/DefaultMethod.kt");
doTest(fileName);
}
@TestMetadata("Delegation.kt")
public void testDelegation() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/method/Delegation.kt");