FIR: avoid resolve loop between accessor and other members
#KT-48634 Fixed
This commit is contained in:
committed by
teamcityserver
parent
72fa330576
commit
19a75b31f9
+73
@@ -0,0 +1,73 @@
|
|||||||
|
FILE: accessInSetter.kt
|
||||||
|
public final class DrawableGrid : R|kotlin/Any| {
|
||||||
|
public constructor(isEnabled: R|kotlin/Boolean|): R|DrawableGrid| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final var isEnabled: R|kotlin/Boolean| = R|<local>/isEnabled|
|
||||||
|
public get(): R|kotlin/Boolean|
|
||||||
|
public set(value: R|kotlin/Boolean|): R|kotlin/Unit|
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class My : R|kotlin/Any| {
|
||||||
|
public constructor(): R|My| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
private final val drawableGrid: R|DrawableGrid| = this@R|/My|.R|/My.createDrawableGrid|()
|
||||||
|
private get(): R|DrawableGrid|
|
||||||
|
|
||||||
|
private final var useAll: R|kotlin/Boolean| = Boolean(false)
|
||||||
|
private get(): R|kotlin/Boolean|
|
||||||
|
private set(value: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||||
|
this@R|/My|.R|/My.drawableGrid|.R|/DrawableGrid.isEnabled| = R|<local>/value|.R|kotlin/Boolean.not|()
|
||||||
|
}
|
||||||
|
|
||||||
|
private final fun createDrawableGrid(): R|DrawableGrid| {
|
||||||
|
^createDrawableGrid R|/DrawableGrid.DrawableGrid|(Boolean(false)).R|kotlin/apply|<R|DrawableGrid|>(<L> = apply@fun R|DrawableGrid|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||||
|
when () {
|
||||||
|
this@R|/My|.R|/My.useAll| -> {
|
||||||
|
Int(-1)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Int(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class Your : R|kotlin/Any| {
|
||||||
|
public constructor(): R|Your| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
private final val drawableGrid: R|DrawableGrid| = this@R|/Your|.R|/Your.createDrawableGrid|()
|
||||||
|
private get(): R|DrawableGrid|
|
||||||
|
|
||||||
|
private final var useAll: R|kotlin/Boolean|
|
||||||
|
private get(): R|kotlin/Boolean| {
|
||||||
|
^ Boolean(false)
|
||||||
|
}
|
||||||
|
private set(value: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||||
|
this@R|/Your|.R|/Your.drawableGrid|.R|/DrawableGrid.isEnabled| = R|<local>/value|.R|kotlin/Boolean.not|()
|
||||||
|
}
|
||||||
|
|
||||||
|
private final fun createDrawableGrid(): R|DrawableGrid| {
|
||||||
|
^createDrawableGrid R|/DrawableGrid.DrawableGrid|(Boolean(false)).R|kotlin/apply|<R|DrawableGrid|>(<L> = apply@fun R|DrawableGrid|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||||
|
when () {
|
||||||
|
this@R|/Your|.R|/Your.useAll| -> {
|
||||||
|
Int(-1)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Int(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
class DrawableGrid(var isEnabled: Boolean)
|
||||||
|
|
||||||
|
class My {
|
||||||
|
private val drawableGrid = createDrawableGrid()
|
||||||
|
|
||||||
|
private var useAll = false
|
||||||
|
set(value) {
|
||||||
|
drawableGrid.isEnabled = !value
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createDrawableGrid() = DrawableGrid(false).apply {
|
||||||
|
if (useAll) -1 else 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Your {
|
||||||
|
private val drawableGrid = createDrawableGrid()
|
||||||
|
|
||||||
|
private var useAll
|
||||||
|
get() = false
|
||||||
|
set(value) {
|
||||||
|
drawableGrid.isEnabled = !value
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createDrawableGrid() = DrawableGrid(false).apply {
|
||||||
|
if (useAll) -1 else 0
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -5034,6 +5034,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
|||||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij")
|
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
public class Intellij {
|
public class Intellij {
|
||||||
|
@Test
|
||||||
|
@TestMetadata("accessInSetter.kt")
|
||||||
|
public void testAccessInSetter() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/accessInSetter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInIntellij() throws Exception {
|
public void testAllFilesPresentInIntellij() throws Exception {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||||
|
|||||||
+6
@@ -5034,6 +5034,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
|||||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij")
|
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
public class Intellij {
|
public class Intellij {
|
||||||
|
@Test
|
||||||
|
@TestMetadata("accessInSetter.kt")
|
||||||
|
public void testAccessInSetter() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/accessInSetter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInIntellij() throws Exception {
|
public void testAllFilesPresentInIntellij() throws Exception {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||||
|
|||||||
+35
-14
@@ -47,7 +47,6 @@ import org.jetbrains.kotlin.fir.visitors.FirDefaultTransformer
|
|||||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.name.SpecialNames
|
|
||||||
|
|
||||||
open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) {
|
open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) {
|
||||||
private val statusResolver: FirStatusResolver = FirStatusResolver(session, scopeSession)
|
private val statusResolver: FirStatusResolver = FirStatusResolver(session, scopeSession)
|
||||||
@@ -126,17 +125,23 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
}
|
}
|
||||||
|
|
||||||
val returnTypeRef = property.returnTypeRef
|
val returnTypeRef = property.returnTypeRef
|
||||||
if (property.initializerAndAccessorsAreResolved) return property
|
val bodyResolveState = property.bodyResolveState
|
||||||
|
if (bodyResolveState == FirPropertyBodyResolveState.EVERYTHING_RESOLVED) return property
|
||||||
if (returnTypeRef !is FirImplicitTypeRef && implicitTypeOnly) return property
|
if (returnTypeRef !is FirImplicitTypeRef && implicitTypeOnly) return property
|
||||||
|
|
||||||
property.transformReceiverTypeRef(transformer, ResolutionMode.ContextIndependent)
|
property.transformReceiverTypeRef(transformer, ResolutionMode.ContextIndependent)
|
||||||
dataFlowAnalyzer.enterProperty(property)
|
dataFlowAnalyzer.enterProperty(property)
|
||||||
doTransformTypeParameters(property)
|
doTransformTypeParameters(property)
|
||||||
|
val shouldResolveEverything = !implicitTypeOnly
|
||||||
return withFullBodyResolve {
|
return withFullBodyResolve {
|
||||||
|
val initializerIsAlreadyResolved = bodyResolveState >= FirPropertyBodyResolveState.INITIALIZER_RESOLVED
|
||||||
context.withProperty(property) {
|
context.withProperty(property) {
|
||||||
context.forPropertyInitializer {
|
context.forPropertyInitializer {
|
||||||
property.transformDelegate(transformer, ResolutionMode.ContextDependentDelegate)
|
property.transformDelegate(transformer, ResolutionMode.ContextDependentDelegate)
|
||||||
property.transformChildrenWithoutAccessors(returnTypeRef)
|
if (!initializerIsAlreadyResolved) {
|
||||||
|
property.transformChildrenWithoutAccessors(returnTypeRef)
|
||||||
|
property.replaceBodyResolveState(FirPropertyBodyResolveState.INITIALIZER_RESOLVED)
|
||||||
|
}
|
||||||
if (property.initializer != null) {
|
if (property.initializer != null) {
|
||||||
storeVariableReturnType(property)
|
storeVariableReturnType(property)
|
||||||
}
|
}
|
||||||
@@ -147,14 +152,26 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
if (property.delegateFieldSymbol != null) {
|
if (property.delegateFieldSymbol != null) {
|
||||||
replacePropertyReferenceTypeInDelegateAccessors(property)
|
replacePropertyReferenceTypeInDelegateAccessors(property)
|
||||||
}
|
}
|
||||||
|
property.replaceBodyResolveState(FirPropertyBodyResolveState.EVERYTHING_RESOLVED)
|
||||||
} else {
|
} else {
|
||||||
property.transformAccessors()
|
val hasNonDefaultAccessors = property.getter != null && property.getter !is FirDefaultPropertyAccessor ||
|
||||||
|
property.setter != null && property.setter !is FirDefaultPropertyAccessor
|
||||||
|
val mayResolveSetter = shouldResolveEverything || !hasNonDefaultAccessors
|
||||||
|
val mayResolveGetter = mayResolveSetter || property.initializer == null
|
||||||
|
if (mayResolveGetter) {
|
||||||
|
property.transformAccessors(mayResolveSetter)
|
||||||
|
property.replaceBodyResolveState(
|
||||||
|
if (mayResolveSetter) FirPropertyBodyResolveState.EVERYTHING_RESOLVED
|
||||||
|
else FirPropertyBodyResolveState.INITIALIZER_AND_GETTER_RESOLVED
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dataFlowAnalyzer.exitProperty(property)?.let {
|
if (!initializerIsAlreadyResolved) {
|
||||||
property.replaceControlFlowGraphReference(FirControlFlowGraphReferenceImpl(it))
|
dataFlowAnalyzer.exitProperty(property)?.let {
|
||||||
|
property.replaceControlFlowGraphReference(FirControlFlowGraphReferenceImpl(it))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
property.replaceInitializerAndAccessorsAreResolved(true)
|
|
||||||
property
|
property
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,10 +310,12 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
.transformOtherChildren(transformer, data)
|
.transformOtherChildren(transformer, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirProperty.transformAccessors() {
|
private fun FirProperty.transformAccessors(mayResolveSetter: Boolean = true) {
|
||||||
var enhancedTypeRef = returnTypeRef
|
var enhancedTypeRef = returnTypeRef
|
||||||
getter?.let {
|
if (bodyResolveState < FirPropertyBodyResolveState.INITIALIZER_AND_GETTER_RESOLVED) {
|
||||||
transformAccessor(it, enhancedTypeRef, this)
|
getter?.let {
|
||||||
|
transformAccessor(it, enhancedTypeRef, this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (returnTypeRef is FirImplicitTypeRef) {
|
if (returnTypeRef is FirImplicitTypeRef) {
|
||||||
storeVariableReturnType(this)
|
storeVariableReturnType(this)
|
||||||
@@ -304,11 +323,13 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
// We need update type of getter for case when its type was approximated
|
// We need update type of getter for case when its type was approximated
|
||||||
getter?.replaceReturnTypeRef(enhancedTypeRef)
|
getter?.replaceReturnTypeRef(enhancedTypeRef)
|
||||||
}
|
}
|
||||||
setter?.let {
|
if (mayResolveSetter) {
|
||||||
if (it.valueParameters[0].returnTypeRef is FirImplicitTypeRef) {
|
setter?.let {
|
||||||
it.valueParameters[0].transformReturnTypeRef(StoreType, enhancedTypeRef)
|
if (it.valueParameters[0].returnTypeRef is FirImplicitTypeRef) {
|
||||||
|
it.valueParameters[0].transformReturnTypeRef(StoreType, enhancedTypeRef)
|
||||||
|
}
|
||||||
|
transformAccessor(it, enhancedTypeRef, this)
|
||||||
}
|
}
|
||||||
transformAccessor(it, enhancedTypeRef, this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
|
|||||||
abstract val backingFieldSymbol: FirBackingFieldSymbol
|
abstract val backingFieldSymbol: FirBackingFieldSymbol
|
||||||
abstract val delegateFieldSymbol: FirDelegateFieldSymbol?
|
abstract val delegateFieldSymbol: FirDelegateFieldSymbol?
|
||||||
abstract val isLocal: Boolean
|
abstract val isLocal: Boolean
|
||||||
abstract val initializerAndAccessorsAreResolved: Boolean
|
abstract val bodyResolveState: FirPropertyBodyResolveState
|
||||||
abstract override val typeParameters: List<FirTypeParameter>
|
abstract override val typeParameters: List<FirTypeParameter>
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitProperty(this, data)
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitProperty(this, data)
|
||||||
@@ -71,7 +71,7 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, FirControlFl
|
|||||||
|
|
||||||
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
|
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
|
||||||
|
|
||||||
abstract fun replaceInitializerAndAccessorsAreResolved(newInitializerAndAccessorsAreResolved: Boolean)
|
abstract fun replaceBodyResolveState(newBodyResolveState: FirPropertyBodyResolveState)
|
||||||
|
|
||||||
abstract override fun <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirProperty
|
abstract override fun <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirProperty
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirPropertyBodyResolveState
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
import org.jetbrains.kotlin.fir.declarations.builder.FirDeclarationBuilder
|
import org.jetbrains.kotlin.fir.declarations.builder.FirDeclarationBuilder
|
||||||
@@ -61,7 +62,7 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder,
|
|||||||
lateinit var symbol: FirPropertySymbol
|
lateinit var symbol: FirPropertySymbol
|
||||||
var delegateFieldSymbol: FirDelegateFieldSymbol? = null
|
var delegateFieldSymbol: FirDelegateFieldSymbol? = null
|
||||||
var isLocal: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
|
var isLocal: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
|
||||||
var initializerAndAccessorsAreResolved: Boolean = false
|
var bodyResolveState: FirPropertyBodyResolveState = FirPropertyBodyResolveState.NOTHING_RESOLVED
|
||||||
override val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
|
override val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
|
||||||
|
|
||||||
override fun build(): FirProperty {
|
override fun build(): FirProperty {
|
||||||
@@ -87,7 +88,7 @@ class FirPropertyBuilder : FirDeclarationBuilder, FirTypeParametersOwnerBuilder,
|
|||||||
symbol,
|
symbol,
|
||||||
delegateFieldSymbol,
|
delegateFieldSymbol,
|
||||||
isLocal,
|
isLocal,
|
||||||
initializerAndAccessorsAreResolved,
|
bodyResolveState,
|
||||||
typeParameters,
|
typeParameters,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -129,7 +130,7 @@ inline fun buildPropertyCopy(original: FirProperty, init: FirPropertyBuilder.()
|
|||||||
copyBuilder.symbol = original.symbol
|
copyBuilder.symbol = original.symbol
|
||||||
copyBuilder.delegateFieldSymbol = original.delegateFieldSymbol
|
copyBuilder.delegateFieldSymbol = original.delegateFieldSymbol
|
||||||
copyBuilder.isLocal = original.isLocal
|
copyBuilder.isLocal = original.isLocal
|
||||||
copyBuilder.initializerAndAccessorsAreResolved = original.initializerAndAccessorsAreResolved
|
copyBuilder.bodyResolveState = original.bodyResolveState
|
||||||
copyBuilder.typeParameters.addAll(original.typeParameters)
|
copyBuilder.typeParameters.addAll(original.typeParameters)
|
||||||
return copyBuilder.apply(init).build()
|
return copyBuilder.apply(init).build()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirPropertyBodyResolveState
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||||
@@ -55,7 +56,7 @@ internal class FirPropertyImpl(
|
|||||||
override val symbol: FirPropertySymbol,
|
override val symbol: FirPropertySymbol,
|
||||||
override val delegateFieldSymbol: FirDelegateFieldSymbol?,
|
override val delegateFieldSymbol: FirDelegateFieldSymbol?,
|
||||||
override val isLocal: Boolean,
|
override val isLocal: Boolean,
|
||||||
override var initializerAndAccessorsAreResolved: Boolean,
|
override var bodyResolveState: FirPropertyBodyResolveState,
|
||||||
override val typeParameters: MutableList<FirTypeParameter>,
|
override val typeParameters: MutableList<FirTypeParameter>,
|
||||||
) : FirProperty() {
|
) : FirProperty() {
|
||||||
override val isVal: Boolean get() = !isVar
|
override val isVal: Boolean get() = !isVar
|
||||||
@@ -169,7 +170,7 @@ internal class FirPropertyImpl(
|
|||||||
controlFlowGraphReference = newControlFlowGraphReference
|
controlFlowGraphReference = newControlFlowGraphReference
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun replaceInitializerAndAccessorsAreResolved(newInitializerAndAccessorsAreResolved: Boolean) {
|
override fun replaceBodyResolveState(newBodyResolveState: FirPropertyBodyResolveState) {
|
||||||
initializerAndAccessorsAreResolved = newInitializerAndAccessorsAreResolved
|
bodyResolveState = newBodyResolveState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.declarations
|
||||||
|
|
||||||
|
// Semantically all states here are parts of FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE and just BODY_RESOLVE
|
||||||
|
enum class FirPropertyBodyResolveState {
|
||||||
|
NOTHING_RESOLVED,
|
||||||
|
INITIALIZER_RESOLVED,
|
||||||
|
INITIALIZER_AND_GETTER_RESOLVED,
|
||||||
|
EVERYTHING_RESOLVED
|
||||||
|
}
|
||||||
+3
-3
@@ -82,8 +82,8 @@ class FirSyntheticProperty(
|
|||||||
// ???
|
// ???
|
||||||
override val backingFieldSymbol: FirBackingFieldSymbol = FirBackingFieldSymbol(symbol.callableId)
|
override val backingFieldSymbol: FirBackingFieldSymbol = FirBackingFieldSymbol(symbol.callableId)
|
||||||
|
|
||||||
override val initializerAndAccessorsAreResolved: Boolean
|
override val bodyResolveState: FirPropertyBodyResolveState
|
||||||
get() = true
|
get() = FirPropertyBodyResolveState.EVERYTHING_RESOLVED
|
||||||
|
|
||||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||||
returnTypeRef.accept(visitor, data)
|
returnTypeRef.accept(visitor, data)
|
||||||
@@ -158,7 +158,7 @@ class FirSyntheticProperty(
|
|||||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun replaceInitializerAndAccessorsAreResolved(newInitializerAndAccessorsAreResolved: Boolean) {
|
override fun replaceBodyResolveState(newBodyResolveState: FirPropertyBodyResolveState) {
|
||||||
throw AssertionError("Mutation of synthetic property isn't supported")
|
throw AssertionError("Mutation of synthetic property isn't supported")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -202,7 +202,7 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
|
|||||||
parents += typeParametersOwnerBuilder
|
parents += typeParametersOwnerBuilder
|
||||||
defaultNull("getter", "setter", "containerSource", "delegateFieldSymbol")
|
defaultNull("getter", "setter", "containerSource", "delegateFieldSymbol")
|
||||||
default("resolvePhase", "FirResolvePhase.RAW_FIR")
|
default("resolvePhase", "FirResolvePhase.RAW_FIR")
|
||||||
defaultFalse("initializerAndAccessorsAreResolved")
|
default("bodyResolveState", "FirPropertyBodyResolveState.NOTHING_RESOLVED")
|
||||||
withCopy()
|
withCopy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -318,7 +318,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
+field("backingFieldSymbol", backingFieldSymbolType)
|
+field("backingFieldSymbol", backingFieldSymbolType)
|
||||||
+field("delegateFieldSymbol", delegateFieldSymbolType, nullable = true)
|
+field("delegateFieldSymbol", delegateFieldSymbolType, nullable = true)
|
||||||
+booleanField("isLocal")
|
+booleanField("isLocal")
|
||||||
+booleanField("initializerAndAccessorsAreResolved", withReplace = true)
|
+field("bodyResolveState", propertyBodyResolveStateType, withReplace = true)
|
||||||
+typeParameters
|
+typeParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ val implicitNothingTypeRefType = generatedType("types.impl", "FirImplicitNothing
|
|||||||
val implicitStringTypeRefType = generatedType("types.impl", "FirImplicitStringTypeRef")
|
val implicitStringTypeRefType = generatedType("types.impl", "FirImplicitStringTypeRef")
|
||||||
val implicitUnitTypeRefType = generatedType("types.impl", "FirImplicitUnitTypeRef")
|
val implicitUnitTypeRefType = generatedType("types.impl", "FirImplicitUnitTypeRef")
|
||||||
val resolvePhaseType = type("fir.declarations", "FirResolvePhase")
|
val resolvePhaseType = type("fir.declarations", "FirResolvePhase")
|
||||||
|
val propertyBodyResolveStateType = type("fir.declarations", "FirPropertyBodyResolveState")
|
||||||
val stubReferenceType = generatedType("references.impl", "FirStubReference")
|
val stubReferenceType = generatedType("references.impl", "FirStubReference")
|
||||||
|
|
||||||
val firBasedSymbolType = type("fir.symbols", "FirBasedSymbol")
|
val firBasedSymbolType = type("fir.symbols", "FirBasedSymbol")
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ internal object DeclarationCopyBuilder {
|
|||||||
setter = copySetter
|
setter = copySetter
|
||||||
|
|
||||||
if (propertyResolvePhase < FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
if (propertyResolvePhase < FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
||||||
initializerAndAccessorsAreResolved = false
|
bodyResolveState = FirPropertyBodyResolveState.NOTHING_RESOLVED
|
||||||
}
|
}
|
||||||
|
|
||||||
initDeclaration(this@withBodyFrom, propertyWithBody)
|
initDeclaration(this@withBodyFrom, propertyWithBody)
|
||||||
|
|||||||
+1
-1
@@ -200,7 +200,7 @@ internal class ReanalyzablePropertyStructureElement(
|
|||||||
getter?.replaceResolvePhase(upgradedPhase)
|
getter?.replaceResolvePhase(upgradedPhase)
|
||||||
setter?.replaceResolvePhase(upgradedPhase)
|
setter?.replaceResolvePhase(upgradedPhase)
|
||||||
replaceResolvePhase(upgradedPhase)
|
replaceResolvePhase(upgradedPhase)
|
||||||
replaceInitializerAndAccessorsAreResolved(false)
|
replaceBodyResolveState(FirPropertyBodyResolveState.NOTHING_RESOLVED)
|
||||||
}
|
}
|
||||||
|
|
||||||
val resolvedDeclaration = firLazyDeclarationResolver.lazyResolveDeclaration(
|
val resolvedDeclaration = firLazyDeclarationResolver.lazyResolveDeclaration(
|
||||||
|
|||||||
+6
@@ -5034,6 +5034,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
|||||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij")
|
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
public class Intellij {
|
public class Intellij {
|
||||||
|
@Test
|
||||||
|
@TestMetadata("accessInSetter.kt")
|
||||||
|
public void testAccessInSetter() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij/accessInSetter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInIntellij() throws Exception {
|
public void testAllFilesPresentInIntellij() throws Exception {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/intellij"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user