diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.java index adb292f7c71..7fd55c8eca3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.java @@ -108,8 +108,8 @@ public class JetClass extends JetTypeParameterListOwnerStub imp return body.getAnonymousInitializers(); } - private boolean hasExplicitPrimaryConstructor() { - return getPrimaryConstructorParameterList() != null; + public boolean hasExplicitPrimaryConstructor() { + return getPrimaryConstructor() != null; } @Override diff --git a/compiler/testData/renderer/Classes.kt b/compiler/testData/renderer/Classes.kt index 20e7febcbd7..b8843b33aa6 100644 --- a/compiler/testData/renderer/Classes.kt +++ b/compiler/testData/renderer/Classes.kt @@ -14,6 +14,8 @@ public open class TheClass [AnotherAnnotation] () { protected abstract fun foo() {} + [TheAnnotation] private constructor() + private class Inner {} } @@ -38,9 +40,9 @@ public trait TwoUpperBounds where T : Number, T : Any //internal final annotation class AnotherAnnotation : kotlin.Annotation defined in rendererTest //public constructor AnotherAnnotation() defined in rendererTest.AnotherAnnotation //rendererTest.TheAnnotation public open class TheClass defined in rendererTest -//rendererTest.AnotherAnnotation public constructor TheClass() defined in rendererTest.TheClass // defined in rendererTest.TheClass // defined in rendererTest.TheClass +//rendererTest.AnotherAnnotation public constructor TheClass() defined in rendererTest.TheClass //private final val privateVal: kotlin.Int defined in rendererTest.TheClass //internal final val shouldBeFinal: kotlin.Int defined in rendererTest.TheClass //internal final val T.checkTypeParameterScope: kotlin.Int defined in rendererTest.TheClass @@ -49,6 +51,7 @@ public trait TwoUpperBounds where T : Number, T : Any //internal final val checkTypeParameterScope2: kotlin.Int defined in rendererTest.TheClass // defined in rendererTest.TheClass.checkTypeParameterScope2 //protected abstract fun foo(): kotlin.Unit defined in rendererTest.TheClass +//rendererTest.TheAnnotation private constructor TheClass() defined in rendererTest.TheClass //private final class Inner defined in rendererTest.TheClass //public constructor Inner() defined in rendererTest.TheClass.Inner //internal final class InternalClass defined in rendererTest diff --git a/compiler/testData/renderer/KeywordsInNames.kt b/compiler/testData/renderer/KeywordsInNames.kt index 360d166de3c..a47640ccc14 100644 --- a/compiler/testData/renderer/KeywordsInNames.kt +++ b/compiler/testData/renderer/KeywordsInNames.kt @@ -22,8 +22,8 @@ val NOT_IS = 3 //internal val `val`: kotlin.Int defined in root package //`true` internal trait `trait` defined in root package //internal final class `class`<`in`> defined in root package -//public constructor `class`<`in`>(p: `in`?) defined in `class` //<`in`> defined in `class` +//public constructor `class`<`in`>(p: `in`?) defined in `class` //value-parameter val p: `in`? defined in `class`. //internal final inner class `class` defined in `class` //public constructor `class`() defined in `class`.`class` diff --git a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt index bf71d051f49..01262edb777 100644 --- a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt @@ -106,7 +106,12 @@ public abstract class AbstractDescriptorRendererTest : KotlinTestWithEnvironment val descriptor = getDescriptor(element, resolveSession) descriptors.add(descriptor) if (descriptor is ClassDescriptor) { - descriptors.addAll(descriptor.getConstructors()) + // if class has primary constructor then we visit it later, otherwise add it artificially + if (element !is JetClass || !element.hasExplicitPrimaryConstructor()) { + if (descriptor.getUnsubstitutedPrimaryConstructor() != null) { + descriptors.add(descriptor.getUnsubstitutedPrimaryConstructor()) + } + } } element.acceptChildren(this) }