[FIR] Add @PrivateForInline to prevent setting to var's from inconvenient places
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
@Experimental(level = Experimental.Level.ERROR)
|
||||||
|
annotation class PrivateForInline
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.resolve.calls
|
package org.jetbrains.kotlin.fir.resolve.calls
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.PrivateForInline
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
|
import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
|
||||||
import kotlin.coroutines.Continuation
|
import kotlin.coroutines.Continuation
|
||||||
|
|
||||||
@@ -15,17 +16,13 @@ abstract class CheckerSink {
|
|||||||
|
|
||||||
abstract val needYielding: Boolean
|
abstract val needYielding: Boolean
|
||||||
|
|
||||||
@Deprecated(
|
@PrivateForInline
|
||||||
"This function yields unconditionally, exposed only for yieldIfNeed",
|
|
||||||
level = DeprecationLevel.WARNING,
|
|
||||||
replaceWith = ReplaceWith("yieldIfNeed")
|
|
||||||
)
|
|
||||||
abstract suspend fun yield()
|
abstract suspend fun yield()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseExperimental(PrivateForInline::class)
|
||||||
suspend inline fun CheckerSink.yieldIfNeed() {
|
suspend inline fun CheckerSink.yieldIfNeed() {
|
||||||
if (needYielding) {
|
if (needYielding) {
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
yield()
|
yield()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,11 +34,13 @@ suspend inline fun CheckerSink.yieldApplicability(new: CandidateApplicability) {
|
|||||||
|
|
||||||
class CheckerSinkImpl(override val components: InferenceComponents, var continuation: Continuation<Unit>? = null) : CheckerSink() {
|
class CheckerSinkImpl(override val components: InferenceComponents, var continuation: Continuation<Unit>? = null) : CheckerSink() {
|
||||||
var current = CandidateApplicability.RESOLVED
|
var current = CandidateApplicability.RESOLVED
|
||||||
|
private set
|
||||||
|
|
||||||
override fun reportApplicability(new: CandidateApplicability) {
|
override fun reportApplicability(new: CandidateApplicability) {
|
||||||
if (new < current) current = new
|
if (new < current) current = new
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("OverridingDeprecatedMember")
|
@PrivateForInline
|
||||||
override suspend fun yield() = kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn<Unit> {
|
override suspend fun yield() = kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn<Unit> {
|
||||||
continuation = it
|
continuation = it
|
||||||
kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
|
kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
|
||||||
|
|||||||
+8
-6
@@ -5,10 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirCallResolver
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.FirQualifiedNameResolver
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
|
||||||
import org.jetbrains.kotlin.fir.FirSymbolOwner
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
@@ -28,6 +25,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef
|
|||||||
abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAbstractPhaseTransformer<ResolutionMode>(phase) {
|
abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAbstractPhaseTransformer<ResolutionMode>(phase) {
|
||||||
abstract val components: BodyResolveTransformerComponents
|
abstract val components: BodyResolveTransformerComponents
|
||||||
|
|
||||||
|
@set:PrivateForInline
|
||||||
abstract var implicitTypeOnly: Boolean
|
abstract var implicitTypeOnly: Boolean
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
@@ -52,6 +50,7 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseExperimental(PrivateForInline::class)
|
||||||
internal inline fun <T> withFullBodyResolve(crossinline l: () -> T): T {
|
internal inline fun <T> withFullBodyResolve(crossinline l: () -> T): T {
|
||||||
if (!implicitTypeOnly) return l()
|
if (!implicitTypeOnly) return l()
|
||||||
implicitTypeOnly = false
|
implicitTypeOnly = false
|
||||||
@@ -99,6 +98,7 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb
|
|||||||
|
|
||||||
override val noExpectedType: FirTypeRef = buildImplicitTypeRef()
|
override val noExpectedType: FirTypeRef = buildImplicitTypeRef()
|
||||||
|
|
||||||
|
@set:PrivateForInline
|
||||||
override lateinit var file: FirFile
|
override lateinit var file: FirFile
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
@@ -128,15 +128,17 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb
|
|||||||
IntegerLiteralTypeApproximationTransformer(symbolProvider, inferenceComponents.ctx)
|
IntegerLiteralTypeApproximationTransformer(symbolProvider, inferenceComponents.ctx)
|
||||||
override val integerOperatorsTypeUpdater: IntegerOperatorsTypeUpdater = IntegerOperatorsTypeUpdater(integerLiteralTypeApproximator)
|
override val integerOperatorsTypeUpdater: IntegerOperatorsTypeUpdater = IntegerOperatorsTypeUpdater(integerLiteralTypeApproximator)
|
||||||
|
|
||||||
@PublishedApi
|
@set:PrivateForInline
|
||||||
internal var containerIfAny: FirDeclaration? = null
|
var containerIfAny: FirDeclaration? = null
|
||||||
|
|
||||||
override var container: FirDeclaration
|
override var container: FirDeclaration
|
||||||
get() = containerIfAny!!
|
get() = containerIfAny!!
|
||||||
private set(value) {
|
private set(value) {
|
||||||
|
@UseExperimental(PrivateForInline::class)
|
||||||
containerIfAny = value
|
containerIfAny = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseExperimental(PrivateForInline::class)
|
||||||
inline fun <T> withContainer(declaration: FirDeclaration, crossinline f: () -> T): T {
|
inline fun <T> withContainer(declaration: FirDeclaration, crossinline f: () -> T): T {
|
||||||
val prevContainer = containerIfAny
|
val prevContainer = containerIfAny
|
||||||
containerIfAny = declaration
|
containerIfAny = declaration
|
||||||
|
|||||||
+3
-5
@@ -5,12 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirElement
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
|
||||||
import org.jetbrains.kotlin.fir.FirTargetElement
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.render
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
||||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
||||||
@@ -40,8 +37,9 @@ open class FirBodyResolveTransformer(
|
|||||||
private val controlFlowStatementsTransformer = FirControlFlowStatementsResolveTransformer(this)
|
private val controlFlowStatementsTransformer = FirControlFlowStatementsResolveTransformer(this)
|
||||||
|
|
||||||
override fun transformFile(file: FirFile, data: ResolutionMode): CompositeTransformResult<FirFile> {
|
override fun transformFile(file: FirFile, data: ResolutionMode): CompositeTransformResult<FirFile> {
|
||||||
packageFqName = file.packageFqName
|
@UseExperimental(PrivateForInline::class)
|
||||||
components.file = file
|
components.file = file
|
||||||
|
packageFqName = file.packageFqName
|
||||||
return withScopeCleanup(components.topLevelScopes) {
|
return withScopeCleanup(components.topLevelScopes) {
|
||||||
components.topLevelScopes.addImportingScopes(file, session, components.scopeSession)
|
components.topLevelScopes.addImportingScopes(file, session, components.scopeSession)
|
||||||
super.transformFile(file, data)
|
super.transformFile(file, data)
|
||||||
|
|||||||
+2
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirElement
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
|
import org.jetbrains.kotlin.fir.PrivateForInline
|
||||||
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
||||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ abstract class FirPartialBodyResolveTransformer(
|
|||||||
@Suppress("OVERRIDE_BY_INLINE")
|
@Suppress("OVERRIDE_BY_INLINE")
|
||||||
final override inline val components: BodyResolveTransformerComponents get() = transformer.components
|
final override inline val components: BodyResolveTransformerComponents get() = transformer.components
|
||||||
|
|
||||||
|
@set:PrivateForInline
|
||||||
override var implicitTypeOnly: Boolean
|
override var implicitTypeOnly: Boolean
|
||||||
get() = transformer.implicitTypeOnly
|
get() = transformer.implicitTypeOnly
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user