Refine descriptor renderer test
Now it checks: - Whether resolveToDescriptor on secondary constructors works well - If there is explicit primary constructor declaration resolveToDescriptor should return it - Renderer itself works well with constructors
This commit is contained in:
@@ -108,8 +108,8 @@ public class JetClass extends JetTypeParameterListOwnerStub<KotlinClassStub> imp
|
||||
return body.getAnonymousInitializers();
|
||||
}
|
||||
|
||||
private boolean hasExplicitPrimaryConstructor() {
|
||||
return getPrimaryConstructorParameterList() != null;
|
||||
public boolean hasExplicitPrimaryConstructor() {
|
||||
return getPrimaryConstructor() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,8 @@ public open class TheClass<out T : Int, X> [AnotherAnnotation] () {
|
||||
|
||||
protected abstract fun foo() {}
|
||||
|
||||
[TheAnnotation] private constructor()
|
||||
|
||||
private class Inner {}
|
||||
}
|
||||
|
||||
@@ -38,9 +40,9 @@ public trait TwoUpperBounds<T> 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<out T : kotlin.Int, X> defined in rendererTest
|
||||
//rendererTest.AnotherAnnotation public constructor TheClass<out T : kotlin.Int, X>() defined in rendererTest.TheClass
|
||||
//<out T : kotlin.Int> defined in rendererTest.TheClass
|
||||
//<X> defined in rendererTest.TheClass
|
||||
//rendererTest.AnotherAnnotation public constructor TheClass<out T : kotlin.Int, X>() 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> T.checkTypeParameterScope: kotlin.Int defined in rendererTest.TheClass
|
||||
@@ -49,6 +51,7 @@ public trait TwoUpperBounds<T> where T : Number, T : Any
|
||||
//internal final val <T> checkTypeParameterScope2: kotlin.Int defined in rendererTest.TheClass
|
||||
//<T> defined in rendererTest.TheClass.checkTypeParameterScope2
|
||||
//protected abstract fun foo(): kotlin.Unit defined in rendererTest.TheClass
|
||||
//rendererTest.TheAnnotation private constructor TheClass<out T : kotlin.Int, X>() 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
|
||||
|
||||
@@ -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`.<init>
|
||||
//internal final inner class `class` defined in `class`
|
||||
//public constructor `class`() defined in `class`.`class`
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user