[FIR] Refactor effective visibility calculation

Before this commit, we had effective visibility as a part of FIR status,
so it was integrated into the full pipeline. In this commit,
we introduced "effective visibility as a service" which is now used
only by exposed visibility checker. This allows us to make the thing
universal for all FIR nodes, including nodes for Java / deserialized.
This commit is contained in:
Nick
2020-07-15 17:23:21 +03:00
committed by Mikhail Glukhikh
parent b15e32936e
commit 7145caca40
95 changed files with 713 additions and 484 deletions
@@ -30,16 +30,16 @@ FILE: CallBasedInExpressionGenerator.kt
private final fun gen(argument: R|ERROR CLASS: Symbol not found, for `StackValue`|): R|ERROR CLASS: Symbol not found, for `BranchedValue`| {
^gen object : R|ERROR CLASS: Symbol not found, for `BranchedValue`| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|ERROR CLASS: Symbol not found, for `BranchedValue`|>(R|<local>/argument|, Null(null), R|<local>/argument|.<Unresolved name: type>#, <Unresolved name: Opcodes>#.<Unresolved name: IFEQ>#)
}
public[local] final override fun putSelector(type: R|ERROR CLASS: Symbol not found, for `Type`|, kotlinType: R|ERROR CLASS: Symbol not found, for `KotlinType?`|, v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|): R|kotlin/Unit| {
public final override fun putSelector(type: R|ERROR CLASS: Symbol not found, for `Type`|, kotlinType: R|ERROR CLASS: Symbol not found, for `KotlinType?`|, v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|): R|kotlin/Unit| {
this@R|/<anonymous>|.R|/<anonymous>.invokeFunction|(R|<local>/v|)
<Unresolved name: coerceTo>#(R|<local>/type|, R|<local>/kotlinType|, R|<local>/v|)
}
public[local] final override fun condJump(jumpLabel: R|ERROR CLASS: Symbol not found, for `Label`|, v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|, jumpIfFalse: R|kotlin/Boolean|): R|kotlin/Unit| {
public final override fun condJump(jumpLabel: R|ERROR CLASS: Symbol not found, for `Label`|, v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|, jumpIfFalse: R|kotlin/Boolean|): R|kotlin/Unit| {
this@R|/<anonymous>|.R|/<anonymous>.invokeFunction|(R|<local>/v|)
R|<local>/v|.<Unresolved name: visitJumpInsn>#(when () {
R|<local>/jumpIfFalse| -> {
@@ -52,7 +52,7 @@ FILE: CallBasedInExpressionGenerator.kt
, R|<local>/jumpLabel|)
}
private[local] final fun invokeFunction(v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|): R|kotlin/Unit| {
private final fun invokeFunction(v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|): R|kotlin/Unit| {
lval result: <ERROR TYPE REF: Unresolved name: invokeFunction> = this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.codegen|.<Unresolved name: invokeFunction>#(this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|.<Unresolved name: call>#, this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|, <Unresolved name: none>#())
R|<local>/result|.<Unresolved name: put>#(R|<local>/result|.<Unresolved name: type>#, R|<local>/result|.<Unresolved name: kotlinType>#, R|<local>/v|)
}
@@ -7,11 +7,11 @@ FILE: enumEntryUse.kt
public final static enum entry FIRST: R|TestEnum|
public final static enum entry SECOND: R|TestEnum|
public final static enum entry THIRD: R|TestEnum| = object : R|TestEnum| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|TestEnum|>()
}
public[local] final fun foo(): R|kotlin/Unit| {
public final fun foo(): R|kotlin/Unit| {
}
}
@@ -6,11 +6,11 @@ FILE: localClassAccessesContainingClass.kt
public final fun foo(): R|kotlin/Unit| {
local final class Local : R|kotlin/Any| {
public[local] constructor(): R|Outer.Local| {
public constructor(): R|Outer.Local| {
super<R|kotlin/Any|>()
}
public[local] final fun bar(): R|kotlin/Unit| {
public final fun bar(): R|kotlin/Unit| {
lval x: R|kotlin/String| = this@R|/Outer|.R|/Outer.y|
}
@@ -1,7 +1,7 @@
FILE: localConstructor.kt
public final fun test(): R|kotlin/Unit| {
local final class Local : R|kotlin/Any| {
public[local] constructor(): R|Local| {
public constructor(): R|Local| {
super<R|kotlin/Any|>()
}
@@ -1,15 +1,15 @@
FILE: localImplicitBodies.kt
public final fun foo(): R|kotlin/Unit| {
lval x: R|<anonymous>| = object : R|kotlin/Any| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
public[local] final fun sss(): R|kotlin/Int| {
public final fun sss(): R|kotlin/Int| {
^sss this@R|/<anonymous>|.R|/<anonymous>.abc|()
}
public[local] final fun abc(): R|kotlin/Int| {
public final fun abc(): R|kotlin/Int| {
^abc Int(1)
}
@@ -3,20 +3,20 @@ FILE: localInnerClass.kt
}
public final fun bar(): R|kotlin/Unit| {
object : R|Foo| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
public[local] final fun foo(): R|Foo| {
public final fun foo(): R|Foo| {
^foo this@R|/<anonymous>|.R|/<anonymous>.Derived.Derived|(Int(42))
}
local final inner class Derived : R|Foo| {
public[local] constructor(x: R|kotlin/Int|): R|<anonymous>.Derived| {
public constructor(x: R|kotlin/Int|): R|<anonymous>.Derived| {
super<R|kotlin/Any|>()
}
public[local] final val x: R|kotlin/Int| = R|<local>/x|
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
@@ -21,7 +21,7 @@ FILE: localObjects.kt
public final fun test(): R|kotlin/Unit| {
Q|A|.R|/A.x|
lval b: R|<anonymous>| = object : R|Foo| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|Foo|>()
}
@@ -29,11 +29,11 @@ FILE: localObjects.kt
R|<local>/b|.R|/Foo.foo|()
local final object B : R|kotlin/Any| {
private[local] constructor(): R|B| {
private constructor(): R|B| {
super<R|kotlin/Any|>()
}
public[local] final fun foo(): R|kotlin/Unit| {
public final fun foo(): R|kotlin/Unit| {
}
}
@@ -10,11 +10,11 @@ FILE: localScopes.kt
}
public final fun test(): R|kotlin/Unit| {
local open class BaseLocal : R|Bar| {
public[local] constructor(): R|BaseLocal| {
public constructor(): R|BaseLocal| {
super<R|Bar|>()
}
public[local] final fun baz(): R|kotlin/Unit| {
public final fun baz(): R|kotlin/Unit| {
}
}
@@ -23,11 +23,11 @@ FILE: localScopes.kt
R|<local>/base|.R|/BaseLocal.baz|()
R|<local>/base|.R|/Bar.foo|()
lval anonymous: R|<anonymous>| = object : R|Bar| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|Bar|>()
}
public[local] final fun baz(): R|kotlin/Unit| {
public final fun baz(): R|kotlin/Unit| {
}
}
@@ -35,11 +35,11 @@ FILE: localScopes.kt
R|<local>/anonymous|.R|/<anonymous>.baz|()
R|<local>/anonymous|.R|/Bar.foo|()
local final class DerivedLocal : R|BaseLocal| {
public[local] constructor(): R|DerivedLocal| {
public constructor(): R|DerivedLocal| {
super<R|BaseLocal|>()
}
public[local] final fun gau(): R|kotlin/Unit| {
public final fun gau(): R|kotlin/Unit| {
}
}
@@ -4,24 +4,24 @@ FILE: localTypes.kt
public final fun foo(): R|kotlin/Unit| {
lval x: R|kotlin/Int| = Int(1)
local final class Bar : R|Foo| {
public[local] constructor(): R|Bar| {
public constructor(): R|Bar| {
super<R|kotlin/Any|>()
}
public[local] final val y: R|kotlin/String| = String()
public final val y: R|kotlin/String| = String()
public get(): R|kotlin/String|
public[local] final fun R|kotlin/Int|.bar(s: R|kotlin/String|): R|kotlin/Boolean| {
public final fun R|kotlin/Int|.bar(s: R|kotlin/String|): R|kotlin/Boolean| {
lval z: R|kotlin/Double| = Double(0.0)
^bar Boolean(true)
}
public[local] final val R|kotlin/Boolean|.w: R|kotlin/Char|
public final val R|kotlin/Boolean|.w: R|kotlin/Char|
public get(): R|kotlin/Char| {
^ Char( )
}
public[local] final fun <T : R|Foo|> id(arg: R|T|): R|T| {
public final fun <T : R|Foo|> id(arg: R|T|): R|T| {
^id R|<local>/arg|
}
@@ -1,19 +1,19 @@
FILE: foo.kt
public final fun foo(): R|kotlin/Boolean| {
object : R|Node<kotlin/Boolean>| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
private[local] final var result: R|kotlin/Boolean| = Boolean(false)
private final var result: R|kotlin/Boolean| = Boolean(false)
private get(): R|kotlin/Boolean|
private set(value: R|kotlin/Boolean|): R|kotlin/Unit|
public[local] final fun bar(): R|kotlin/Boolean| {
public final fun bar(): R|kotlin/Boolean| {
^bar this@R|/<anonymous>|.R|/<anonymous>.result|.R|kotlin/Boolean.not|()
}
public[local] final override fun result(): R|kotlin/Boolean| {
public final override fun result(): R|kotlin/Boolean| {
^result this@R|/<anonymous>|.R|/<anonymous>.result|
}
@@ -5,28 +5,28 @@ FILE: nestedVisibility.kt
}
private final class PrivateNested : R|kotlin/Any| {
public[private] constructor(): R|Outer.PrivateNested| {
public constructor(): R|Outer.PrivateNested| {
super<R|kotlin/Any|>()
}
}
private final inner class PrivateInner : R|kotlin/Any| {
public[private] constructor(): R|Outer.PrivateInner| {
public constructor(): R|Outer.PrivateInner| {
super<R|kotlin/Any|>()
}
}
protected final class ProtectedNested : R|kotlin/Any| {
public[protected] constructor(): R|Outer.ProtectedNested| {
public constructor(): R|Outer.ProtectedNested| {
super<R|kotlin/Any|>()
}
}
protected final inner class ProtectedInner : R|kotlin/Any| {
public[protected] constructor(): R|Outer.ProtectedInner| {
public constructor(): R|Outer.ProtectedInner| {
super<R|kotlin/Any|>()
}
@@ -14,7 +14,7 @@ FILE: O.kt
}
private final class Derived : R|Base| {
public[private] constructor(bar: R|kotlin/Int|): R|O.Derived| {
public constructor(bar: R|kotlin/Int|): R|O.Derived| {
super<R|Base|>()
}
@@ -22,30 +22,30 @@ FILE: O.kt
private get(): R|kotlin/Int|
private final inner class Some : R|kotlin/Any| {
public[private] constructor(z: R|kotlin/Boolean|): R|O.Derived.Some| {
public constructor(z: R|kotlin/Boolean|): R|O.Derived.Some| {
super<R|kotlin/Any|>()
}
public[private] final val z: R|kotlin/Boolean| = R|<local>/z|
public final val z: R|kotlin/Boolean| = R|<local>/z|
public get(): R|kotlin/Boolean|
public[private] final fun test(): R|kotlin/Unit| {
public final fun test(): R|kotlin/Unit| {
lval x: R|kotlin/Int| = this@R|/O.Derived|.R|/O.Derived.bar|
lval o: R|<anonymous>| = object : R|Wrapper| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|Wrapper|>(this@R|/O.Derived.Some|.R|/O.Derived.Some.z|)
}
public[local] final fun local(): R|kotlin/Unit| {
public final fun local(): R|kotlin/Unit| {
lval y: R|ft<kotlin/String, kotlin/String?>!| = this@R|/O.Derived|.R|/Base.foo|()
}
public[local] final val oo: R|<anonymous>| = object : R|kotlin/Any| {
private[local] constructor(): R|<anonymous>| {
public final val oo: R|<anonymous>| = object : R|kotlin/Any| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
public[local] final val zz: R|kotlin/Boolean| = this@R|/O.Derived.Some|.R|/O.Derived.Some.z|
public final val zz: R|kotlin/Boolean| = this@R|/O.Derived.Some|.R|/O.Derived.Some.z|
public get(): R|kotlin/Boolean|
}
@@ -58,14 +58,14 @@ FILE: O.kt
}
public[private] final fun test(): R|kotlin/Unit| {
public final fun test(): R|kotlin/Unit| {
lval x: R|kotlin/Int| = this@R|/O.Derived|.R|/O.Derived.bar|
lval o: R|<anonymous>| = object : R|kotlin/Any| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
public[local] final fun local(): R|kotlin/Unit| {
public final fun local(): R|kotlin/Unit| {
lval y: R|ft<kotlin/String, kotlin/String?>!| = this@R|/O.Derived|.R|/Base.foo|()
}
@@ -86,11 +86,11 @@ FILE: O.kt
private final fun gen(): R|kotlin/Any| {
^gen object : R|Wrapper| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|Wrapper|>(Boolean(true))
}
private[local] final fun invokeFunction(): R|kotlin/Unit| {
private final fun invokeFunction(): R|kotlin/Unit| {
lval c: R|kotlin/Any| = this@R|/Generator|.R|/Generator.codegen|
lval cc: R|kotlin/Int| = this@R|/Generator|.R|/Generator.codegen|.R|kotlin/Any.hashCode|()
}
@@ -5,11 +5,11 @@ FILE: privateObjectLiteral.kt
}
private final val x: R|<anonymous>| = object : R|kotlin/Any| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
public[local] final fun foo(): R|kotlin/Int| {
public final fun foo(): R|kotlin/Int| {
^foo Int(42)
}
@@ -21,11 +21,11 @@ FILE: privateObjectLiteral.kt
public get(): R|kotlin/Int|
internal final val z: R|<anonymous>| = object : R|kotlin/Any| {
private[local] constructor(): R|<anonymous>| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
public[local] final fun foo(): R|kotlin/Int| {
public final fun foo(): R|kotlin/Int| {
^foo Int(13)
}
@@ -2,26 +2,26 @@ FILE: first.kt
private final fun foo(): R|kotlin/Unit| {
}
private final class Private : R|kotlin/Any| {
public[private] constructor(): R|Private| {
public constructor(): R|Private| {
super<R|kotlin/Any|>()
}
private final fun bar(): R|kotlin/Unit| {
}
public[private] final fun baz(): R|kotlin/Unit| {
public final fun baz(): R|kotlin/Unit| {
this@R|/Private|.R|/Private.bar|()
R|/Private.Nested.Nested|()
this@R|/Private.Companion|.R|/Private.Companion.fromCompanion|()
Q|Private.NotCompanion|.<HIDDEN: /Private.NotCompanion.foo is invisible>#()
}
public[private] final inner class Inner : R|kotlin/Any| {
public[private] constructor(): R|Private.Inner| {
public final inner class Inner : R|kotlin/Any| {
public constructor(): R|Private.Inner| {
super<R|kotlin/Any|>()
}
public[private] final fun foo(): R|kotlin/Unit| {
public final fun foo(): R|kotlin/Unit| {
this@R|/Private|.R|/Private.bar|()
this@R|/Private.Companion|.R|/Private.Companion.fromCompanion|()
Q|Private.NotCompanion|.<HIDDEN: /Private.NotCompanion.foo is invisible>#()
@@ -30,18 +30,18 @@ FILE: first.kt
}
private final class Nested : R|kotlin/Any| {
public[private] constructor(): R|Private.Nested| {
public constructor(): R|Private.Nested| {
super<R|kotlin/Any|>()
}
public[private] final fun foo(): R|kotlin/Unit| {
public final fun foo(): R|kotlin/Unit| {
this@R|/Private.Companion|.R|/Private.Companion.fromCompanion|()
Q|Private.NotCompanion|.<HIDDEN: /Private.NotCompanion.foo is invisible>#()
}
}
public[private] final companion object Companion : R|kotlin/Any| {
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|Private.Companion| {
super<R|kotlin/Any|>()
}
@@ -51,7 +51,7 @@ FILE: first.kt
}
public[private] final object NotCompanion : R|kotlin/Any| {
public final object NotCompanion : R|kotlin/Any| {
private constructor(): R|Private.NotCompanion| {
super<R|kotlin/Any|>()
}
@@ -64,23 +64,23 @@ FILE: first.kt
}
public final fun withLocals(): R|kotlin/Unit| {
local final class Local : R|kotlin/Any| {
public[local] constructor(): R|Local| {
public constructor(): R|Local| {
super<R|kotlin/Any|>()
}
private[local] final fun bar(): R|kotlin/Unit|
private final fun bar(): R|kotlin/Unit|
public[local] final fun baz(): R|kotlin/Unit| {
public final fun baz(): R|kotlin/Unit| {
this@R|/Local|.R|/Local.bar|()
this@R|/Local|.R|/Local.Inner.Inner|()
}
local final inner class Inner : R|kotlin/Any| {
public[local] constructor(): R|Local.Inner| {
public constructor(): R|Local.Inner| {
super<R|kotlin/Any|>()
}
public[local] final fun foo(): R|kotlin/Unit| {
public final fun foo(): R|kotlin/Unit| {
this@R|/Local|.R|/Local.bar|()
}
@@ -24,11 +24,11 @@ FILE: protectedVisibility.kt
}
protected open class Nested : R|kotlin/Any| {
public[protected] constructor(): R|Protected.Nested| {
public constructor(): R|Protected.Nested| {
super<R|kotlin/Any|>()
}
public[protected] final fun foo(): R|kotlin/Unit| {
public final fun foo(): R|kotlin/Unit| {
this@R|/Protected.Nested|.R|/Protected.Nested.bar|()
}
@@ -42,7 +42,7 @@ FILE: protectedVisibility.kt
super<R|kotlin/Any|>()
}
public[protected] final fun fromCompanion(): R|kotlin/Unit| {
public final fun fromCompanion(): R|kotlin/Unit| {
}
protected final fun protectedFromCompanion(): R|kotlin/Unit| {
@@ -65,11 +65,11 @@ FILE: protectedVisibility.kt
}
private final class NestedDerived : R|Protected.Nested| {
public[private] constructor(): R|Derived.NestedDerived| {
public constructor(): R|Derived.NestedDerived| {
super<R|Protected.Nested|>()
}
public[private] final fun use(): R|kotlin/Unit| {
public final fun use(): R|kotlin/Unit| {
this@R|/Derived.NestedDerived|.R|/Protected.Nested.bar|()
}