[FIR] Support some approximation of effective visibility
This commit is contained in:
+2
-2
@@ -18,7 +18,7 @@ FILE: propertiesAndInitBlocks.kt
|
||||
}
|
||||
|
||||
local final class LocalClass : R|kotlin/Any| {
|
||||
public constructor(): R|LocalClass| {
|
||||
public[local] constructor(): R|LocalClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ FILE: propertiesAndInitBlocks.kt
|
||||
)
|
||||
public get(): R|kotlin/Unit| {
|
||||
local final class LocalClass : R|kotlin/Any| {
|
||||
public constructor(): R|LocalClass| {
|
||||
public[local] constructor(): R|LocalClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -6,11 +6,11 @@ FILE: localClassAccessesContainingClass.kt
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
local final class Local : R|kotlin/Any| {
|
||||
public constructor(): R|Outer.Local| {
|
||||
public[local] constructor(): R|Outer.Local| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
public[local] final fun bar(): R|kotlin/Unit| {
|
||||
lval x: R|kotlin/String| = this@R|/Outer|.R|/Outer.y|
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
FILE: localConstructor.kt
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
local final class Local : R|kotlin/Any| {
|
||||
public constructor(): R|Local| {
|
||||
public[local] constructor(): R|Local| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@ FILE: localInnerClass.kt
|
||||
}
|
||||
|
||||
local final inner class Derived : R|Foo| {
|
||||
public constructor(x: R|kotlin/Int|): R|<anonymous>.Derived| {
|
||||
public[local] constructor(x: R|kotlin/Int|): R|<anonymous>.Derived| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = R|<local>/x|
|
||||
public[local] final val x: R|kotlin/Int| = R|<local>/x|
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ FILE: localObjects.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
public[local] 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 constructor(): R|BaseLocal| {
|
||||
public[local] constructor(): R|BaseLocal| {
|
||||
super<R|Bar|>()
|
||||
}
|
||||
|
||||
public final fun baz(): R|kotlin/Unit| {
|
||||
public[local] 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 constructor(): R|DerivedLocal| {
|
||||
public[local] constructor(): R|DerivedLocal| {
|
||||
super<R|BaseLocal|>()
|
||||
}
|
||||
|
||||
public final fun gau(): R|kotlin/Unit| {
|
||||
public[local] 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 constructor(): R|Bar| {
|
||||
public[local] constructor(): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val y: R|kotlin/String| = String()
|
||||
public[local] final val y: R|kotlin/String| = String()
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final fun R|kotlin/Int|.bar(s: R|kotlin/String|): R|kotlin/Boolean| {
|
||||
public[local] 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 final val R|kotlin/Boolean|.w: R|kotlin/Char|
|
||||
public[local] final val R|kotlin/Boolean|.w: R|kotlin/Char|
|
||||
public get(): R|kotlin/Char| {
|
||||
^ Char( )
|
||||
}
|
||||
|
||||
public final fun <T : R|Foo|> id(arg: R|T|): R|T| {
|
||||
public[local] final fun <T : R|Foo|> id(arg: R|T|): R|T| {
|
||||
^id R|<local>/arg|
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -5,28 +5,28 @@ FILE: nestedVisibility.kt
|
||||
}
|
||||
|
||||
private final class PrivateNested : R|kotlin/Any| {
|
||||
public constructor(): R|Outer.PrivateNested| {
|
||||
public[private] constructor(): R|Outer.PrivateNested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final inner class PrivateInner : R|kotlin/Any| {
|
||||
public constructor(): R|Outer.PrivateInner| {
|
||||
public[private] constructor(): R|Outer.PrivateInner| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final class ProtectedNested : R|kotlin/Any| {
|
||||
public constructor(): R|Outer.ProtectedNested| {
|
||||
public[protected] constructor(): R|Outer.ProtectedNested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final inner class ProtectedInner : R|kotlin/Any| {
|
||||
public constructor(): R|Outer.ProtectedInner| {
|
||||
public[protected] constructor(): R|Outer.ProtectedInner| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -14,7 +14,7 @@ FILE: O.kt
|
||||
}
|
||||
|
||||
private final class Derived : R|Base| {
|
||||
public constructor(bar: R|kotlin/Int|): R|O.Derived| {
|
||||
public[private] constructor(bar: R|kotlin/Int|): R|O.Derived| {
|
||||
super<R|Base|>()
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ FILE: O.kt
|
||||
private get(): R|kotlin/Int|
|
||||
|
||||
private final inner class Some : R|kotlin/Any| {
|
||||
public constructor(z: R|kotlin/Boolean|): R|O.Derived.Some| {
|
||||
public[private] constructor(z: R|kotlin/Boolean|): R|O.Derived.Some| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val z: R|kotlin/Boolean| = R|<local>/z|
|
||||
public[private] final val z: R|kotlin/Boolean| = R|<local>/z|
|
||||
public get(): R|kotlin/Boolean|
|
||||
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
public[private] 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 constructor(): R|anonymous| {
|
||||
@@ -58,7 +58,7 @@ FILE: O.kt
|
||||
|
||||
}
|
||||
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
public[private] 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 constructor(): R|anonymous| {
|
||||
|
||||
+13
-13
@@ -2,26 +2,26 @@ FILE: first.kt
|
||||
private final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
private final class Private : R|kotlin/Any| {
|
||||
public constructor(): R|Private| {
|
||||
public[private] constructor(): R|Private| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun bar(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun baz(): R|kotlin/Unit| {
|
||||
public[private] 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|.<Inapplicable(HIDDEN): [/Private.NotCompanion.foo]>#()
|
||||
}
|
||||
|
||||
public final inner class Inner : R|kotlin/Any| {
|
||||
public constructor(): R|Private.Inner| {
|
||||
public[private] final inner class Inner : R|kotlin/Any| {
|
||||
public[private] constructor(): R|Private.Inner| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
public[private] final fun foo(): R|kotlin/Unit| {
|
||||
this@R|/Private|.R|/Private.bar|()
|
||||
this@R|/Private.Companion|.R|/Private.Companion.fromCompanion|()
|
||||
Q|Private.NotCompanion|.<Inapplicable(HIDDEN): [/Private.NotCompanion.foo]>#()
|
||||
@@ -30,18 +30,18 @@ FILE: first.kt
|
||||
}
|
||||
|
||||
private final class Nested : R|kotlin/Any| {
|
||||
public constructor(): R|Private.Nested| {
|
||||
public[private] constructor(): R|Private.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
public[private] final fun foo(): R|kotlin/Unit| {
|
||||
this@R|/Private.Companion|.R|/Private.Companion.fromCompanion|()
|
||||
Q|Private.NotCompanion|.<Inapplicable(HIDDEN): [/Private.NotCompanion.foo]>#()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
public[private] final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|Private.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
@@ -51,7 +51,7 @@ FILE: first.kt
|
||||
|
||||
}
|
||||
|
||||
public final object NotCompanion : R|kotlin/Any| {
|
||||
public[private] 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 constructor(): R|Local| {
|
||||
public[local] constructor(): R|Local| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final fun bar(): R|kotlin/Unit|
|
||||
|
||||
public final fun baz(): R|kotlin/Unit| {
|
||||
public[local] final fun baz(): R|kotlin/Unit| {
|
||||
R|/Local.bar|()
|
||||
this@R|/Local|.R|/Local.Inner.Inner|()
|
||||
}
|
||||
|
||||
local final inner class Inner : R|kotlin/Any| {
|
||||
public constructor(): R|Local.Inner| {
|
||||
public[local] constructor(): R|Local.Inner| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
public[local] final fun foo(): R|kotlin/Unit| {
|
||||
R|/Local.bar|()
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -24,11 +24,11 @@ FILE: protectedVisibility.kt
|
||||
}
|
||||
|
||||
protected open class Nested : R|kotlin/Any| {
|
||||
public constructor(): R|Protected.Nested| {
|
||||
public[protected (in different classes)] constructor(): R|Protected.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
public[protected (in different classes)] 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 final fun fromCompanion(): R|kotlin/Unit| {
|
||||
public[protected] 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 constructor(): R|Derived.NestedDerived| {
|
||||
public[private] constructor(): R|Derived.NestedDerived| {
|
||||
super<R|Protected.Nested|>()
|
||||
}
|
||||
|
||||
public final fun use(): R|kotlin/Unit| {
|
||||
public[private] final fun use(): R|kotlin/Unit| {
|
||||
this@R|/Derived.NestedDerived|.R|/Protected.Nested.bar|()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,11 +4,11 @@ FILE: callableReferenceToLocalClass.kt
|
||||
}
|
||||
public final fun test_1(): R|kotlin/Unit| {
|
||||
local final class Data : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/Int|): R|Data| {
|
||||
public[local] constructor(x: R|kotlin/Int|): R|Data| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = R|<local>/x|
|
||||
public[local] final val x: R|kotlin/Int| = R|<local>/x|
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
|
||||
@@ -5,15 +5,15 @@ FILE: objectInnerClass.kt
|
||||
}
|
||||
|
||||
local final inner class Child : R|ERROR CLASS: Symbol not found, for `Base`| {
|
||||
public constructor(property: R|B|): R|<anonymous>.Child| {
|
||||
public[local] constructor(property: R|B|): R|<anonymous>.Child| {
|
||||
super<R|ERROR CLASS: Symbol not found, for `Base`|>(R|<local>/property|)
|
||||
}
|
||||
|
||||
public final fun R|ERROR CLASS: Symbol not found, for `Base`|.zoo(): R|kotlin/Unit| {
|
||||
public[local] final fun R|ERROR CLASS: Symbol not found, for `Base`|.zoo(): R|kotlin/Unit| {
|
||||
lval x: <ERROR TYPE REF: Unresolved name: property> = <Unresolved name: property>#
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
public[local] final fun foo(): R|kotlin/Unit| {
|
||||
<Unresolved name: baseFun>#()
|
||||
lval x: <ERROR TYPE REF: Unresolved name: property> = <Unresolved name: property>#
|
||||
<Unresolved name: zoo>#()
|
||||
@@ -31,14 +31,14 @@ FILE: objectInnerClass.kt
|
||||
}
|
||||
|
||||
local open inner class Base : R|kotlin/Any| {
|
||||
public constructor(property: R|B|): R|<anonymous>.Base| {
|
||||
public[local] constructor(property: R|B|): R|<anonymous>.Base| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val property: R|B| = R|<local>/property|
|
||||
public[local] final val property: R|B| = R|<local>/property|
|
||||
public get(): R|B|
|
||||
|
||||
public final fun baseFun(): R|kotlin/Unit| {
|
||||
public[local] final fun baseFun(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -130,15 +130,15 @@ FILE: objectInnerClass.kt
|
||||
}
|
||||
|
||||
local final inner class Child : R|ERROR CLASS: Symbol not found, for `Base`| {
|
||||
public constructor(property: R|B|): R|Case3.<anonymous>.Child| {
|
||||
public[local] constructor(property: R|B|): R|Case3.<anonymous>.Child| {
|
||||
super<R|ERROR CLASS: Symbol not found, for `Base`|>(R|<local>/property|)
|
||||
}
|
||||
|
||||
public final fun R|ERROR CLASS: Symbol not found, for `Base`|.zoo(): R|kotlin/Unit| {
|
||||
public[local] final fun R|ERROR CLASS: Symbol not found, for `Base`|.zoo(): R|kotlin/Unit| {
|
||||
lval x: <ERROR TYPE REF: Unresolved name: property> = <Unresolved name: property>#
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
public[local] final fun foo(): R|kotlin/Unit| {
|
||||
<Unresolved name: baseFun>#()
|
||||
lval x: <ERROR TYPE REF: Unresolved name: property> = <Unresolved name: property>#
|
||||
this@R|/Case3.<anonymous>.Child|.R|/Case3.<anonymous>.Child.zoo|()
|
||||
@@ -156,14 +156,14 @@ FILE: objectInnerClass.kt
|
||||
}
|
||||
|
||||
local open inner class Base : R|kotlin/Any| {
|
||||
public constructor(property: R|B|): R|Case3.<anonymous>.Base| {
|
||||
public[local] constructor(property: R|B|): R|Case3.<anonymous>.Base| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val property: R|B| = R|<local>/property|
|
||||
public[local] final val property: R|B| = R|<local>/property|
|
||||
public get(): R|B|
|
||||
|
||||
public final fun baseFun(): R|kotlin/Unit| {
|
||||
public[local] final fun baseFun(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -27,17 +27,17 @@ FILE: hashTableWithForEach.kt
|
||||
}
|
||||
|
||||
private final class Entry<K, V> : R|kotlin/collections/MutableMap.MutableEntry<K, V>| {
|
||||
public constructor<K, V>(key: R|K|, value: R|V|): R|SomeHashTable.Entry<K, V>| {
|
||||
public[private] constructor<K, V>(key: R|K|, value: R|V|): R|SomeHashTable.Entry<K, V>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final override val key: R|K| = R|<local>/key|
|
||||
public[private] final override val key: R|K| = R|<local>/key|
|
||||
public get(): R|K|
|
||||
|
||||
public final override val value: R|V| = R|<local>/value|
|
||||
public[private] final override val value: R|V| = R|<local>/value|
|
||||
public get(): R|V|
|
||||
|
||||
public final override fun setValue(newValue: R|V|): R|V| {
|
||||
public[private] final override fun setValue(newValue: R|V|): R|V| {
|
||||
^setValue throw R|java/lang/UnsupportedOperationException.UnsupportedOperationException|()
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ FILE: problems.kt
|
||||
public get(): R|anonymous|
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
local final class Local : R|kotlin/Any| {
|
||||
public constructor(): R|Local| {
|
||||
public[local] constructor(): R|Local| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.RelationToType
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirEffectiveVisibility.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection
|
||||
|
||||
fun firEffectiveVisibility(
|
||||
session: FirSession,
|
||||
visibility: Visibility,
|
||||
declaration: FirMemberDeclaration?
|
||||
) =
|
||||
visibility.forVisibility(session, declaration)
|
||||
|
||||
fun FirRegularClass.firEffectiveVisibility(session: FirSession, checkPublishedApi: Boolean = false) =
|
||||
firEffectiveVisibility(session, emptySet(), checkPublishedApi)
|
||||
|
||||
fun Visibility.firEffectiveVisibility(session: FirSession, declaration: FirMemberDeclaration?): FirEffectiveVisibility =
|
||||
firEffectiveVisibility(session, normalize(), declaration)
|
||||
|
||||
fun ConeKotlinType.leastPermissiveDescriptor(session: FirSession, base: FirEffectiveVisibility): DeclarationWithRelation? =
|
||||
dependentDeclarations(session).leastPermissive(session, base)
|
||||
|
||||
fun FirMemberDeclaration.firEffectiveVisibility(
|
||||
session: FirSession, visibility: Visibility = this.visibility, checkPublishedApi: Boolean = false
|
||||
): FirEffectiveVisibility =
|
||||
lowerBound(
|
||||
visibility.firEffectiveVisibility(session, this),
|
||||
this.containingClass(session)?.firEffectiveVisibility(session, checkPublishedApi) ?: Public
|
||||
)
|
||||
|
||||
private fun lowerBound(first: FirEffectiveVisibility, second: FirEffectiveVisibility) =
|
||||
first.lowerBound(second)
|
||||
|
||||
private fun FirMemberDeclaration.containingClass(session: FirSession): FirRegularClass? {
|
||||
val classId = when (this) {
|
||||
is FirRegularClass -> symbol.classId.outerClassId
|
||||
is FirCallableMemberDeclaration<*> -> symbol.callableId.classId
|
||||
else -> null
|
||||
} ?: return null
|
||||
if (classId.isLocal) return null
|
||||
return session.firSymbolProvider.getClassLikeSymbolByFqName(classId)?.fir as? FirRegularClass
|
||||
}
|
||||
|
||||
private fun Visibility.forVisibility(
|
||||
session: FirSession, declaration: FirMemberDeclaration?
|
||||
): FirEffectiveVisibility =
|
||||
when (this) {
|
||||
Visibilities.PRIVATE, Visibilities.PRIVATE_TO_THIS, Visibilities.INVISIBLE_FAKE -> Private
|
||||
Visibilities.PROTECTED -> Protected(declaration?.containingClass(session))
|
||||
Visibilities.INTERNAL -> Internal
|
||||
Visibilities.PUBLIC -> Public
|
||||
Visibilities.LOCAL -> Local
|
||||
// NB: visibility must be already normalized here, so e.g. no JavaVisibilities are possible at this point
|
||||
else -> throw AssertionError("Visibility $name is not allowed in forVisibility")
|
||||
}
|
||||
|
||||
class DeclarationWithRelation internal constructor(val declaration: FirMemberDeclaration, private val relation: RelationToType) {
|
||||
fun firEffectiveVisibility(session: FirSession) =
|
||||
declaration.visibility.firEffectiveVisibility(session, declaration)
|
||||
|
||||
override fun toString(): String {
|
||||
val name = when (declaration) {
|
||||
is FirRegularClass -> declaration.name
|
||||
is FirSimpleFunction -> declaration.name
|
||||
is FirVariable<*> -> declaration.name
|
||||
else -> "<anonymous>"
|
||||
}
|
||||
return "$relation $name"
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is DeclarationWithRelation) return false
|
||||
if (declaration != other.declaration) return false
|
||||
if (relation != other.relation) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = declaration.hashCode()
|
||||
result = 31 * result + relation.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirMemberDeclaration.dependentDeclarations(session: FirSession, ownRelation: RelationToType): Set<DeclarationWithRelation> =
|
||||
setOf(DeclarationWithRelation(this, ownRelation)) +
|
||||
(this.containingClass(session)?.dependentDeclarations(session, ownRelation.containerRelation()) ?: emptySet())
|
||||
|
||||
private fun FirRegularClass.firEffectiveVisibility(
|
||||
session: FirSession, classes: Set<FirRegularClass>, checkPublishedApi: Boolean
|
||||
): FirEffectiveVisibility =
|
||||
if (this in classes) Public
|
||||
else with(this.containingClass(session)) {
|
||||
lowerBound(
|
||||
visibility.firEffectiveVisibility(session, this@firEffectiveVisibility),
|
||||
this?.firEffectiveVisibility(session, classes + this@firEffectiveVisibility, checkPublishedApi) ?: Public
|
||||
)
|
||||
}
|
||||
|
||||
// Should collect all dependent classifier descriptors, to get verbose diagnostic
|
||||
private fun ConeKotlinType.dependentDeclarations(session: FirSession) =
|
||||
dependentDeclarations(session, emptySet(), RelationToType.CONSTRUCTOR)
|
||||
|
||||
private fun ConeKotlinType.dependentDeclarations(
|
||||
session: FirSession, types: Set<ConeKotlinType>, ownRelation: RelationToType
|
||||
): Set<DeclarationWithRelation> {
|
||||
if (this in types) return emptySet()
|
||||
val classLikeType = this as? ConeClassLikeType ?: return emptySet()
|
||||
val lookupTag = classLikeType.lookupTag
|
||||
val classSymbol = lookupTag.toSymbol(session) ?: return emptySet()
|
||||
val ownDependent = (classSymbol.fir as? FirMemberDeclaration)?.dependentDeclarations(session, ownRelation) ?: emptySet()
|
||||
val argumentDependent = classLikeType.typeArguments.mapNotNull {
|
||||
(it as? ConeKotlinTypeProjection)?.type?.dependentDeclarations(session, types + this, RelationToType.ARGUMENT)
|
||||
}.flatten()
|
||||
return ownDependent + argumentDependent
|
||||
}
|
||||
|
||||
private fun Set<DeclarationWithRelation>.leastPermissive(session: FirSession, base: FirEffectiveVisibility): DeclarationWithRelation? {
|
||||
for (declarationWithRelation in this) {
|
||||
val currentVisibility = declarationWithRelation.firEffectiveVisibility(session)
|
||||
when (currentVisibility.relation(base)) {
|
||||
Permissiveness.LESS, Permissiveness.UNKNOWN -> {
|
||||
return declarationWithRelation
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
+7
-5
@@ -5,15 +5,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.fir.FirEffectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.firEffectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
import org.jetbrains.kotlin.fir.visitors.compose
|
||||
|
||||
@@ -119,7 +118,10 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer<FirDeclarationSta
|
||||
else -> status.visibility
|
||||
}
|
||||
val modality = status.modality ?: resolveModality(containingClass)
|
||||
return (status as FirDeclarationStatusImpl).resolved(visibility, modality)
|
||||
val containerEffectiveVisibility = containingClass?.effectiveVisibility ?: FirEffectiveVisibility.Public
|
||||
val effectiveVisibility =
|
||||
visibility.firEffectiveVisibility(session, this as? FirMemberDeclaration).lowerBound(containerEffectiveVisibility)
|
||||
return (status as FirDeclarationStatusImpl).resolved(visibility, effectiveVisibility, modality)
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
@@ -102,7 +103,7 @@ class FirIntegerLiteralTypeScope(private val session: FirSession) : FirScope() {
|
||||
FirILTTypeRefPlaceHolder(),
|
||||
receiverTypeRef = null,
|
||||
ALL_OPERATORS.getValue(name),
|
||||
FirResolvedDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL),
|
||||
FirResolvedDeclarationStatusImpl(Visibilities.PUBLIC, FirEffectiveVisibility.Public, Modality.FINAL),
|
||||
symbol
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.BODY_RESOLVE
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirEffectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
@@ -19,6 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
interface FirDeclarationStatus : FirElement {
|
||||
override val source: FirSourceElement?
|
||||
val visibility: Visibility
|
||||
val effectiveVisibility: FirEffectiveVisibility
|
||||
val modality: Modality?
|
||||
val isExpect: Boolean
|
||||
val isActual: Boolean
|
||||
|
||||
+2
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirEffectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
@@ -18,6 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
interface FirResolvedDeclarationStatus : FirDeclarationStatus {
|
||||
override val source: FirSourceElement?
|
||||
override val visibility: Visibility
|
||||
override val effectiveVisibility: FirEffectiveVisibility
|
||||
override val modality: Modality?
|
||||
override val isExpect: Boolean
|
||||
override val isActual: Boolean
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirEffectiveVisibility.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
|
||||
sealed class FirEffectiveVisibility(val name: String, val publicApi: Boolean = false, val privateApi: Boolean = false) {
|
||||
|
||||
override fun toString() = name
|
||||
|
||||
// Public
|
||||
// /--/ | \-------------\
|
||||
// Protected(Base) | \
|
||||
// | Protected(Other) Internal = PackagePrivate
|
||||
// Protected(Derived) | / \
|
||||
// | | / InternalProtected(Base)
|
||||
// ProtectedBound / \
|
||||
// \ / /InternalProtected(Derived)
|
||||
// \InternalProtectedBound/
|
||||
// |
|
||||
// Private = Local
|
||||
|
||||
|
||||
object Private : FirEffectiveVisibility("private", privateApi = true) {
|
||||
override fun relation(other: FirEffectiveVisibility) =
|
||||
if (this == other || Local == other) Permissiveness.SAME else Permissiveness.LESS
|
||||
|
||||
override fun toVisibility() = Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
// Effectively same as Private
|
||||
object Local : FirEffectiveVisibility("local") {
|
||||
override fun relation(other: FirEffectiveVisibility) =
|
||||
if (this == other || Private == other) Permissiveness.SAME else Permissiveness.LESS
|
||||
|
||||
override fun toVisibility() = Visibilities.LOCAL
|
||||
}
|
||||
|
||||
object Public : FirEffectiveVisibility("public", publicApi = true) {
|
||||
override fun relation(other: FirEffectiveVisibility) =
|
||||
if (this == other) Permissiveness.SAME else Permissiveness.MORE
|
||||
|
||||
override fun toVisibility() = Visibilities.PUBLIC
|
||||
}
|
||||
|
||||
abstract class InternalOrPackage protected constructor(internal: Boolean) : FirEffectiveVisibility(
|
||||
if (internal) "internal" else "public/*package*/"
|
||||
) {
|
||||
override fun relation(other: FirEffectiveVisibility) = when (other) {
|
||||
Public -> Permissiveness.LESS
|
||||
Private, Local, InternalProtectedBound, is InternalProtected -> Permissiveness.MORE
|
||||
is InternalOrPackage -> Permissiveness.SAME
|
||||
ProtectedBound, is Protected -> Permissiveness.UNKNOWN
|
||||
}
|
||||
|
||||
override fun lowerBound(other: FirEffectiveVisibility) = when (other) {
|
||||
Public -> this
|
||||
Private, Local, InternalProtectedBound, is InternalOrPackage, is InternalProtected -> other
|
||||
is Protected -> InternalProtected(other.container)
|
||||
ProtectedBound -> InternalProtectedBound
|
||||
}
|
||||
}
|
||||
|
||||
object Internal : InternalOrPackage(true) {
|
||||
override fun toVisibility() = Visibilities.INTERNAL
|
||||
}
|
||||
|
||||
object PackagePrivate : InternalOrPackage(false) {
|
||||
override fun toVisibility() = Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
class Protected(val container: FirRegularClass?) : FirEffectiveVisibility("protected", publicApi = true) {
|
||||
|
||||
override fun equals(other: Any?) = (other is Protected && container == other.container)
|
||||
|
||||
override fun hashCode() = container?.hashCode() ?: 0
|
||||
|
||||
override fun toString() = "${super.toString()} (in ${container?.name ?: '?'})"
|
||||
|
||||
override fun relation(other: FirEffectiveVisibility) = when (other) {
|
||||
Public -> Permissiveness.LESS
|
||||
Private, Local, ProtectedBound, InternalProtectedBound -> Permissiveness.MORE
|
||||
is Protected -> containerRelation(container, other.container)
|
||||
is InternalProtected -> when (containerRelation(container, other.container)) {
|
||||
// Protected never can be less permissive than internal & protected
|
||||
Permissiveness.SAME, Permissiveness.MORE -> Permissiveness.MORE
|
||||
Permissiveness.UNKNOWN, Permissiveness.LESS -> Permissiveness.UNKNOWN
|
||||
}
|
||||
is InternalOrPackage -> Permissiveness.UNKNOWN
|
||||
}
|
||||
|
||||
override fun lowerBound(other: FirEffectiveVisibility) = when (other) {
|
||||
Public -> this
|
||||
Private, Local, ProtectedBound, InternalProtectedBound -> other
|
||||
is Protected -> when (relation(other)) {
|
||||
Permissiveness.SAME, Permissiveness.MORE -> this
|
||||
Permissiveness.LESS -> other
|
||||
Permissiveness.UNKNOWN -> ProtectedBound
|
||||
}
|
||||
is InternalProtected -> when (relation(other)) {
|
||||
Permissiveness.LESS -> other
|
||||
else -> InternalProtectedBound
|
||||
}
|
||||
is InternalOrPackage -> InternalProtected(container)
|
||||
}
|
||||
|
||||
override fun toVisibility() = Visibilities.PROTECTED
|
||||
}
|
||||
|
||||
// Lower bound for all protected visibilities
|
||||
object ProtectedBound : FirEffectiveVisibility("protected (in different classes)", publicApi = true) {
|
||||
override fun relation(other: FirEffectiveVisibility) = when (other) {
|
||||
Public, is Protected -> Permissiveness.LESS
|
||||
Private, Local, InternalProtectedBound -> Permissiveness.MORE
|
||||
ProtectedBound -> Permissiveness.SAME
|
||||
is InternalOrPackage, is InternalProtected -> Permissiveness.UNKNOWN
|
||||
}
|
||||
|
||||
override fun lowerBound(other: FirEffectiveVisibility) = when (other) {
|
||||
Public, is Protected -> this
|
||||
Private, Local, ProtectedBound, InternalProtectedBound -> other
|
||||
is InternalOrPackage, is InternalProtected -> InternalProtectedBound
|
||||
}
|
||||
|
||||
override fun toVisibility() = Visibilities.PROTECTED
|
||||
}
|
||||
|
||||
// Lower bound for internal and protected(C)
|
||||
class InternalProtected(val container: FirRegularClass?) : FirEffectiveVisibility("internal & protected") {
|
||||
|
||||
override fun equals(other: Any?) = (other is InternalProtected && container == other.container)
|
||||
|
||||
override fun hashCode() = container?.hashCode() ?: 0
|
||||
|
||||
override fun toString() = "${super.toString()} (in ${container?.name ?: '?'})"
|
||||
|
||||
override fun relation(other: FirEffectiveVisibility) = when (other) {
|
||||
Public, is InternalOrPackage -> Permissiveness.LESS
|
||||
Private, Local, InternalProtectedBound -> Permissiveness.MORE
|
||||
is InternalProtected -> containerRelation(container, other.container)
|
||||
is Protected -> when (containerRelation(container, other.container)) {
|
||||
// Internal & protected never can be more permissive than just protected
|
||||
Permissiveness.SAME, Permissiveness.LESS -> Permissiveness.LESS
|
||||
Permissiveness.UNKNOWN, Permissiveness.MORE -> Permissiveness.UNKNOWN
|
||||
}
|
||||
ProtectedBound -> Permissiveness.UNKNOWN
|
||||
}
|
||||
|
||||
override fun lowerBound(other: FirEffectiveVisibility) = when (other) {
|
||||
Public, is InternalOrPackage -> this
|
||||
Private, Local, InternalProtectedBound -> other
|
||||
is Protected, is InternalProtected -> when (relation(other)) {
|
||||
Permissiveness.SAME, Permissiveness.MORE -> this
|
||||
Permissiveness.LESS -> other
|
||||
Permissiveness.UNKNOWN -> InternalProtectedBound
|
||||
}
|
||||
ProtectedBound -> InternalProtectedBound
|
||||
}
|
||||
|
||||
override fun toVisibility() = Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
// Lower bound for internal and protected lower bound
|
||||
object InternalProtectedBound : FirEffectiveVisibility("internal & protected (in different classes)") {
|
||||
override fun relation(other: FirEffectiveVisibility) = when (other) {
|
||||
Public, is Protected, is InternalProtected, ProtectedBound, is InternalOrPackage -> Permissiveness.LESS
|
||||
Private, Local -> Permissiveness.MORE
|
||||
InternalProtectedBound -> Permissiveness.SAME
|
||||
}
|
||||
|
||||
override fun toVisibility() = Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
enum class Permissiveness {
|
||||
LESS,
|
||||
SAME,
|
||||
MORE,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
abstract fun relation(other: FirEffectiveVisibility): Permissiveness
|
||||
|
||||
abstract fun toVisibility(): Visibility
|
||||
|
||||
open fun lowerBound(other: FirEffectiveVisibility) = when (relation(other)) {
|
||||
Permissiveness.SAME, Permissiveness.LESS -> this
|
||||
Permissiveness.MORE -> other
|
||||
Permissiveness.UNKNOWN -> Private
|
||||
}
|
||||
}
|
||||
|
||||
internal fun containerRelation(first: FirRegularClass?, second: FirRegularClass?): Permissiveness =
|
||||
if (first == null || second == null) {
|
||||
Permissiveness.UNKNOWN
|
||||
} else if (first == second) {
|
||||
Permissiveness.SAME
|
||||
// TODO
|
||||
// } else if (DescriptorUtils.isSubclass(first, second)) {
|
||||
// Permissiveness.LESS
|
||||
// } else if (DescriptorUtils.isSubclass(second, first)) {
|
||||
// Permissiveness.MORE
|
||||
} else {
|
||||
Permissiveness.UNKNOWN
|
||||
}
|
||||
|
||||
internal fun Visibility.firEffectiveVisibilityApproximation(): FirEffectiveVisibility =
|
||||
when (this) {
|
||||
Visibilities.PUBLIC -> Public
|
||||
Visibilities.PRIVATE -> Private
|
||||
Visibilities.PRIVATE_TO_THIS -> Private
|
||||
Visibilities.INTERNAL -> Internal
|
||||
Visibilities.LOCAL -> Local
|
||||
Visibilities.PROTECTED -> ProtectedBound
|
||||
else -> Public
|
||||
}
|
||||
|
||||
@@ -41,6 +41,13 @@ fun FirElement.render(mode: FirRenderer.RenderMode = FirRenderer.RenderMode.Norm
|
||||
buildString { this@render.accept(FirRenderer(this, mode)) }
|
||||
|
||||
class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderMode.Normal) : FirVisitorVoid() {
|
||||
companion object {
|
||||
private val visibilitiesToRenderEffectiveSet = setOf(
|
||||
Visibilities.PRIVATE, Visibilities.PRIVATE_TO_THIS, Visibilities.INTERNAL,
|
||||
Visibilities.PROTECTED, Visibilities.PUBLIC, Visibilities.LOCAL
|
||||
)
|
||||
}
|
||||
|
||||
abstract class RenderMode(val renderLambdaBodies: Boolean, val renderCallArguments: Boolean) {
|
||||
object Normal : RenderMode(renderLambdaBodies = true, renderCallArguments = true)
|
||||
}
|
||||
@@ -152,11 +159,18 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
||||
callableDeclaration.returnTypeRef.accept(this)
|
||||
}
|
||||
|
||||
private fun Visibility.asString() =
|
||||
when (this) {
|
||||
Visibilities.UNKNOWN -> "public?"
|
||||
private fun Visibility.asString(effectiveVisibility: FirEffectiveVisibility? = null): String {
|
||||
val itself = when (this) {
|
||||
Visibilities.UNKNOWN -> return "public?"
|
||||
else -> toString()
|
||||
}
|
||||
if (effectiveVisibility == null) return itself
|
||||
val effectiveAsVisibility = effectiveVisibility.toVisibility()
|
||||
if (effectiveAsVisibility == this) return itself
|
||||
if (effectiveAsVisibility == Visibilities.PRIVATE && this == Visibilities.PRIVATE_TO_THIS) return itself
|
||||
if (this !in visibilitiesToRenderEffectiveSet) return itself
|
||||
return itself + "[${effectiveVisibility.name}]"
|
||||
}
|
||||
|
||||
private fun FirMemberDeclaration.modalityAsString(): String {
|
||||
return modality?.name?.toLowerCase() ?: run {
|
||||
@@ -187,7 +201,8 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
||||
override fun visitMemberDeclaration(memberDeclaration: FirMemberDeclaration) {
|
||||
memberDeclaration.annotations.renderAnnotations()
|
||||
if (memberDeclaration !is FirProperty || !memberDeclaration.isLocal) {
|
||||
print(memberDeclaration.visibility.asString() + " " + memberDeclaration.modalityAsString() + " ")
|
||||
print(memberDeclaration.visibility.asString(memberDeclaration.effectiveVisibility) + " ")
|
||||
print(memberDeclaration.modalityAsString() + " ")
|
||||
}
|
||||
if (memberDeclaration.isExpect) {
|
||||
print("expect ")
|
||||
@@ -377,7 +392,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
||||
|
||||
override fun visitConstructor(constructor: FirConstructor) {
|
||||
constructor.annotations.renderAnnotations()
|
||||
print(constructor.visibility.asString() + " constructor")
|
||||
print(constructor.visibility.asString(constructor.effectiveVisibility) + " constructor")
|
||||
constructor.typeParameters.renderTypeParameters()
|
||||
constructor.valueParameters.renderParameters()
|
||||
print(": ")
|
||||
|
||||
@@ -26,6 +26,7 @@ inline val FirRegularClass.isData get() = status.isData
|
||||
inline val FirRegularClass.isInline get() = status.isInline
|
||||
inline val FirMemberDeclaration.modality get() = status.modality
|
||||
inline val FirMemberDeclaration.visibility get() = status.visibility
|
||||
inline val FirMemberDeclaration.effectiveVisibility get() = status.effectiveVisibility
|
||||
inline val FirMemberDeclaration.isActual get() = status.isActual
|
||||
inline val FirMemberDeclaration.isExpect get() = status.isExpect
|
||||
inline val FirMemberDeclaration.isInner get() = status.isInner
|
||||
|
||||
+6
-2
@@ -7,10 +7,12 @@ package org.jetbrains.kotlin.fir.declarations.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirEffectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.FirPureAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl.Modifier.*
|
||||
import org.jetbrains.kotlin.fir.firEffectiveVisibilityApproximation
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
|
||||
@@ -19,6 +21,8 @@ open class FirDeclarationStatusImpl(
|
||||
override val modality: Modality?
|
||||
) : FirPureAbstractElement(), FirDeclarationStatus {
|
||||
override val source: FirSourceElement? get() = null
|
||||
override val effectiveVisibility: FirEffectiveVisibility
|
||||
get() = visibility.firEffectiveVisibilityApproximation()
|
||||
protected var flags: Int = 0
|
||||
|
||||
private operator fun get(modifier: Modifier): Boolean = (flags and modifier.mask) != 0
|
||||
@@ -159,7 +163,7 @@ open class FirDeclarationStatusImpl(
|
||||
return this
|
||||
}
|
||||
|
||||
fun resolved(visibility: Visibility, modality: Modality): FirDeclarationStatus {
|
||||
return FirResolvedDeclarationStatusImpl(visibility, modality, flags)
|
||||
fun resolved(visibility: Visibility, effectiveVisibility: FirEffectiveVisibility, modality: Modality): FirDeclarationStatus {
|
||||
return FirResolvedDeclarationStatusImpl(visibility, effectiveVisibility, modality, flags)
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -7,18 +7,21 @@ package org.jetbrains.kotlin.fir.declarations.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirEffectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvedDeclarationStatus
|
||||
|
||||
class FirResolvedDeclarationStatusImpl(
|
||||
visibility: Visibility,
|
||||
override var effectiveVisibility: FirEffectiveVisibility,
|
||||
modality: Modality
|
||||
) : FirDeclarationStatusImpl(visibility, modality), FirResolvedDeclarationStatus {
|
||||
|
||||
internal constructor(
|
||||
visibility: Visibility,
|
||||
effectiveVisibility: FirEffectiveVisibility,
|
||||
modality: Modality,
|
||||
flags: Int
|
||||
) : this(visibility, modality) {
|
||||
) : this(visibility, effectiveVisibility, modality) {
|
||||
this.flags = flags
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -75,6 +75,8 @@ object FieldSets {
|
||||
|
||||
val visibility = field(visibilityType)
|
||||
|
||||
val effectiveVisibility = field("effectiveVisibility", effectiveVisibilityType)
|
||||
|
||||
val modality = field(modalityType, nullable = true)
|
||||
|
||||
val scopeProvider = field("scopeProvider", firScopeProviderType)
|
||||
|
||||
+3
@@ -5,12 +5,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.tree.generator
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.effectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.annotations
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.arguments
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.body
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.classKind
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.controlFlowGraphReferenceField
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.declarations
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.effectiveVisibility
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.initializer
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.modality
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.name
|
||||
@@ -303,6 +305,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
|
||||
declarationStatus.configure {
|
||||
+visibility
|
||||
+effectiveVisibility
|
||||
+modality
|
||||
generateBooleanFields(
|
||||
"expect", "actual", "override", "operator", "infix", "inline", "tailRec",
|
||||
|
||||
+2
-4
@@ -6,10 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.tree.generator
|
||||
|
||||
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.generatedType
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.type
|
||||
@@ -29,6 +26,7 @@ val invocationKindType = type(InvocationKind::class)
|
||||
val varianceType = type(Variance::class)
|
||||
val nameType = type(Name::class)
|
||||
val visibilityType = type(Visibility::class)
|
||||
val effectiveVisibilityType = type("fir", "FirEffectiveVisibility")
|
||||
val visibilitiesType = type(Visibilities::class)
|
||||
val modalityType = type(Modality::class)
|
||||
val fqNameType = type(FqName::class)
|
||||
|
||||
Reference in New Issue
Block a user