[FIR] Fix processing constructors of sealed classes

- Allow declaring protected constructors in sealed classes
- Make default visibility of sealed class constructor `protected`

KT-44861
KT-44865
This commit is contained in:
Dmitriy Novozhilov
2021-02-11 13:20:03 +03:00
committed by TeamCityServer
parent 7c61ddc72b
commit 2d5b685535
47 changed files with 98 additions and 106 deletions
@@ -12,7 +12,7 @@ public sealed class Sealed : R|kotlin/Any| {
public final val z: R|test/Z|
public get(): R|test/Z|
@R|test/Ann|() internal constructor(@R|test/Ann|() z: R|test/Z|): R|test/Sealed|
@R|test/Ann|() protected constructor(@R|test/Ann|() z: R|test/Z|): R|test/Sealed|
}
@@ -14,7 +14,7 @@ public sealed class SealedClass : R|kotlin/Any| {
}
internal constructor(): R|test/SealedClass|
protected constructor(): R|test/SealedClass|
}
@@ -44,7 +44,7 @@ FILE: constantValues.kt
}
public sealed class Value : R|kotlin/Any| {
private constructor(): R|KClassValue.Value| {
protected constructor(): R|KClassValue.Value| {
super<R|kotlin/Any|>()
}
@@ -30,13 +30,13 @@ FILE: incompatibleModifiers.kt
}
public final class F : R|kotlin/Any| {
private constructor(): R|F| {
protected constructor(): R|F| {
super<R|kotlin/Any|>()
}
}
public sealed class G : R|kotlin/Any| {
private constructor(): R|G| {
protected constructor(): R|G| {
super<R|kotlin/Any|>()
}
@@ -57,7 +57,7 @@ FILE: incompatibleModifiers.kt
}
public sealed data class I : R|kotlin/Any| {
private constructor(i: R|kotlin/Int|): R|I| {
protected constructor(i: R|kotlin/Int|): R|I| {
super<R|kotlin/Any|>()
}
@@ -126,7 +126,7 @@ FILE: incompatibleModifiers.kt
}
public sealed inner class Z : R|kotlin/Any| {
private constructor(): R|X.Z| {
protected constructor(): R|X.Z| {
super<R|kotlin/Any|>()
}
@@ -6,7 +6,7 @@ FILE: redundantModifier.kt
}
public sealed class B : R|kotlin/Any| {
private constructor(): R|B| {
protected constructor(): R|B| {
super<R|kotlin/Any|>()
}
@@ -1,9 +1,9 @@
FILE: sealedClassConstructorCall.kt
public sealed class A : R|kotlin/Any| {
private constructor(): R|A| {
protected constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public final val b: R|A| = R|/A.A|()
public final val b: R|A| = <HIDDEN: /A.A is invisible>#()
public get(): R|A|
@@ -1,3 +1,3 @@
sealed class A
val b = <!SEALED_CLASS_CONSTRUCTOR_CALL{LT}!><!SEALED_CLASS_CONSTRUCTOR_CALL{PSI}!>A<!>()<!>
val b = <!HIDDEN{LT}!><!HIDDEN{PSI}!>A<!>()<!>
@@ -1,6 +1,6 @@
FILE: sealedSupertype.kt
public sealed class A : R|kotlin/Any| {
private constructor(): R|A| {
protected constructor(): R|A| {
super<R|kotlin/Any|>()
}
@@ -22,7 +22,7 @@ FILE: sealedSupertype.kt
}
public sealed class P : R|kotlin/Any| {
private constructor(): R|P| {
protected constructor(): R|P| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: a.kt
public sealed class Base : R|kotlin/Any| {
private constructor(): R|Base| {
protected constructor(): R|Base| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: exhaustiveness_sealedClass.kt
public sealed class Base : R|kotlin/Any| {
private constructor(): R|Base| {
protected constructor(): R|Base| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: exhaustiveness_sealedObject.kt
public sealed class A : R|kotlin/Any| {
private constructor(): R|A| {
protected constructor(): R|A| {
super<R|kotlin/Any|>()
}
@@ -1,12 +1,12 @@
FILE: exhaustiveness_sealedSubClass.kt
public sealed class A : R|kotlin/Any| {
private constructor(): R|A| {
protected constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public sealed class B : R|A| {
private constructor(): R|B| {
protected constructor(): R|B| {
super<R|A|>()
}
@@ -18,13 +18,13 @@ FILE: exhaustiveness_sealedSubClass.kt
}
public sealed class D : R|B| {
private constructor(): R|D| {
protected constructor(): R|D| {
super<R|B|>()
}
}
public sealed class E : R|B| {
private constructor(): R|E| {
protected constructor(): R|E| {
super<R|B|>()
}
@@ -5,7 +5,7 @@ FILE: classifierAccessFromCompanion.kt
}
public sealed class Function : R|kotlin/Any| {
private constructor(): R|Factory.Function| {
protected constructor(): R|Factory.Function| {
super<R|kotlin/Any|>()
}
@@ -111,7 +111,7 @@ FILE: RedundantVisibilityModifierChecker.kt
}
public sealed class G : R|kotlin/Any| {
private constructor(y: R|kotlin/Int|): R|G| {
protected constructor(y: R|kotlin/Int|): R|G| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: test.kt
public sealed class Test : R|kotlin/Any| {
private constructor(): R|test/Test| {
protected constructor(): R|test/Test| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: recursiveCallOnWhenWithSealedClass.kt
public sealed class Maybe<T> : R|kotlin/Any| {
private constructor<T>(): R|Maybe<T>| {
protected constructor<T>(): R|Maybe<T>| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: sealedClass.kt
public sealed class Foo : R|kotlin/Any| {
private constructor(value: R|kotlin/String|): R|Foo| {
protected constructor(value: R|kotlin/String|): R|Foo| {
super<R|kotlin/Any|>()
}
@@ -2,7 +2,7 @@ FILE: kt37327.kt
public abstract interface Q : R|kotlin/Any| {
}
public sealed class A : R|Q| {
private constructor(): R|A| {
protected constructor(): R|A| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: lambdaInWhenBranch.kt
private sealed class Sealed : R|kotlin/Any| {
private constructor(): R|Sealed| {
protected constructor(): R|Sealed| {
super<R|kotlin/Any|>()
}
@@ -1,6 +1,6 @@
FILE: bareWithSubjectTypeAlias.kt
public sealed class A<out T> : R|kotlin/Any| {
private constructor<out T>(): R|A<T>| {
protected constructor<out T>(): R|A<T>| {
super<R|kotlin/Any|>()
}