Don't resolve kotlin constructors from bytecode without JetConstructorAnnotation

This commit is contained in:
Natalia.Ukhorskaya
2012-12-24 14:39:02 +04:00
parent f4a44155d9
commit f0d52e63b2
11 changed files with 86 additions and 2 deletions
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.*;
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeMethodSignatureData;
import org.jetbrains.jet.lang.resolve.java.kt.JetConstructorAnnotation;
import org.jetbrains.jet.lang.resolve.java.provider.ClassPsiDeclarationProvider;
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
import org.jetbrains.jet.lang.resolve.name.Name;
@@ -167,8 +168,14 @@ public final class JavaConstructorResolver {
) {
PsiMethodWrapper constructor = new PsiMethodWrapper(psiConstructor);
JetConstructorAnnotation constructorAnnotation = constructor.getJetConstructorAnnotation();
//noinspection deprecation
if (constructor.getJetConstructorAnnotation().hidden()) {
if (constructorAnnotation.hidden()) {
return null;
}
// Do not resolve kotlin constructors without JetConstructorAnnotation
if (DescriptorResolverUtils.isKotlinClass(psiClass) && !constructorAnnotation.isDefined()) {
return null;
}
@@ -205,7 +212,7 @@ public final class JavaConstructorResolver {
constructorDescriptor.initialize(classDescriptor.getTypeConstructor().getParameters(),
valueParameterDescriptors.getDescriptors(),
DescriptorResolverUtils.resolveVisibility(psiConstructor, constructor.getJetConstructorAnnotation()),
DescriptorResolverUtils.resolveVisibility(psiConstructor, constructorAnnotation),
aStatic);
trace.record(BindingContext.CONSTRUCTOR, psiConstructor, constructorDescriptor);
return constructorDescriptor;
@@ -0,0 +1,3 @@
package test
class TestConstructor(p: Int = 1, s: Int)
@@ -0,0 +1,5 @@
namespace test
internal final class test.TestConstructor : jet.Any {
public final /*primary constructor*/ fun <init>(/*0*/ p: jet.Int = ?, /*1*/ s: jet.Int): test.TestConstructor
}
@@ -0,0 +1,3 @@
package test
class TestConstructor(p: Int = 1, d: Int = 1)
@@ -0,0 +1,5 @@
namespace test
internal final class test.TestConstructor : jet.Any {
public final /*primary constructor*/ fun <init>(/*0*/ p: jet.Int = ?, /*1*/ d: jet.Int = ?): test.TestConstructor
}
@@ -0,0 +1,5 @@
package test
class A {
class TestConstructor(p: Int = 1)
}
@@ -0,0 +1,8 @@
namespace test
internal final class test.A : jet.Any {
public final /*primary constructor*/ fun <init>(): test.A
internal final class test.A.TestConstructor : jet.Any {
public final /*primary constructor*/ fun <init>(/*0*/ p: jet.Int = ?): test.A.TestConstructor
}
}
@@ -0,0 +1,3 @@
package test
class TestConstructor private(p: Int = 1)
@@ -0,0 +1,5 @@
namespace test
internal final class test.TestConstructor : jet.Any {
private final /*primary constructor*/ fun <init>(/*0*/ p: jet.Int = ?): test.TestConstructor
}
@@ -264,11 +264,21 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
doTest("compiler/testData/loadKotlin/constructor/Constructor1WithParamDefaultValue.kt");
}
@TestMetadata("Constructor2WithOneParamDefaultValue.kt")
public void testConstructor2WithOneParamDefaultValue() throws Exception {
doTest("compiler/testData/loadKotlin/constructor/Constructor2WithOneParamDefaultValue.kt");
}
@TestMetadata("ConstructorCollectionParameter.kt")
public void testConstructorCollectionParameter() throws Exception {
doTest("compiler/testData/loadKotlin/constructor/ConstructorCollectionParameter.kt");
}
@TestMetadata("ConstructorWithTwoDefArgs.kt")
public void testConstructorWithTwoDefArgs() throws Exception {
doTest("compiler/testData/loadKotlin/constructor/ConstructorWithTwoDefArgs.kt");
}
@TestMetadata("ConstructorWithTwoTypeParameters.kt")
public void testConstructorWithTwoTypeParameters() throws Exception {
doTest("compiler/testData/loadKotlin/constructor/ConstructorWithTwoTypeParameters.kt");
@@ -294,6 +304,16 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
doTest("compiler/testData/loadKotlin/constructor/ConstructorWithTypeParametersEAndOnePValueParameter.kt");
}
@TestMetadata("InnerClassConstructorWithDefArgs.kt")
public void testInnerClassConstructorWithDefArgs() throws Exception {
doTest("compiler/testData/loadKotlin/constructor/InnerClassConstructorWithDefArgs.kt");
}
@TestMetadata("PrivateConstructor1WithParamDefaultValue.kt")
public void testPrivateConstructor1WithParamDefaultValue() throws Exception {
doTest("compiler/testData/loadKotlin/constructor/PrivateConstructor1WithParamDefaultValue.kt");
}
}
@TestMetadata("compiler/testData/loadKotlin/dataClass")
@@ -266,11 +266,21 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/Constructor1WithParamDefaultValue.kt");
}
@TestMetadata("Constructor2WithOneParamDefaultValue.kt")
public void testConstructor2WithOneParamDefaultValue() throws Exception {
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/Constructor2WithOneParamDefaultValue.kt");
}
@TestMetadata("ConstructorCollectionParameter.kt")
public void testConstructorCollectionParameter() throws Exception {
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/ConstructorCollectionParameter.kt");
}
@TestMetadata("ConstructorWithTwoDefArgs.kt")
public void testConstructorWithTwoDefArgs() throws Exception {
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/ConstructorWithTwoDefArgs.kt");
}
@TestMetadata("ConstructorWithTwoTypeParameters.kt")
public void testConstructorWithTwoTypeParameters() throws Exception {
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/ConstructorWithTwoTypeParameters.kt");
@@ -296,6 +306,16 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/ConstructorWithTypeParametersEAndOnePValueParameter.kt");
}
@TestMetadata("InnerClassConstructorWithDefArgs.kt")
public void testInnerClassConstructorWithDefArgs() throws Exception {
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/InnerClassConstructorWithDefArgs.kt");
}
@TestMetadata("PrivateConstructor1WithParamDefaultValue.kt")
public void testPrivateConstructor1WithParamDefaultValue() throws Exception {
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/constructor/PrivateConstructor1WithParamDefaultValue.kt");
}
}
@TestMetadata("compiler/testData/loadKotlin/dataClass")