[FIR] do not transform annotations on delegated property accessors during implicit type phase
^KT-62874 Fixed
This commit is contained in:
committed by
Space Team
parent
1b636bf450
commit
3941b05909
+13
-5
@@ -186,7 +186,7 @@ open class FirDeclarationsResolveTransformer(
|
||||
|
||||
property.transformAccessors(SetterResolutionMode.FULLY_RESOLVE, shouldResolveEverything = true)
|
||||
} else {
|
||||
transformPropertyAccessorsWithDelegate(property, delegate)
|
||||
transformPropertyAccessorsWithDelegate(property, delegate, shouldResolveEverything)
|
||||
if (property.delegateFieldSymbol != null) {
|
||||
replacePropertyReferenceTypeInDelegateAccessors(property)
|
||||
}
|
||||
@@ -298,7 +298,11 @@ open class FirDeclarationsResolveTransformer(
|
||||
(property.delegate as? FirFunctionCall)?.replacePropertyReferenceTypeInDelegateAccessors(property)
|
||||
}
|
||||
|
||||
private fun transformPropertyAccessorsWithDelegate(property: FirProperty, delegate: FirExpression) {
|
||||
private fun transformPropertyAccessorsWithDelegate(
|
||||
property: FirProperty,
|
||||
delegate: FirExpression,
|
||||
shouldResolveEverything: Boolean,
|
||||
) {
|
||||
val isImplicitTypedProperty = property.returnTypeRef is FirImplicitTypeRef
|
||||
|
||||
context.forPropertyDelegateAccessors(property, resolutionContext, callCompleter) {
|
||||
@@ -317,7 +321,11 @@ open class FirDeclarationsResolveTransformer(
|
||||
// It's necessary because we need to supply the property type as the 3rd argument for `setValue` and there might be uninferred
|
||||
// variables from `getValue`.
|
||||
// The same logic was used at K1 (see org.jetbrains.kotlin.resolve.DelegatedPropertyResolver.inferDelegateTypeFromGetSetValueMethods)
|
||||
property.transformAccessors(if (isImplicitTypedProperty) SetterResolutionMode.SKIP else SetterResolutionMode.FULLY_RESOLVE)
|
||||
property.transformAccessors(
|
||||
if (isImplicitTypedProperty) SetterResolutionMode.SKIP else SetterResolutionMode.FULLY_RESOLVE,
|
||||
shouldResolveEverything,
|
||||
)
|
||||
|
||||
val completedCalls = completeCandidates()
|
||||
|
||||
val finalSubstitutor = createFinalSubstitutor()
|
||||
@@ -346,7 +354,7 @@ open class FirDeclarationsResolveTransformer(
|
||||
|
||||
// `isImplicitTypedProperty` means we haven't run setter resolution yet (see its second usage)
|
||||
if (isImplicitTypedProperty) {
|
||||
property.resolveSetter(mayResolveSetterBody = true, shouldResolveEverything = true)
|
||||
property.resolveSetter(mayResolveSetterBody = true, shouldResolveEverything = shouldResolveEverything)
|
||||
}
|
||||
|
||||
dataFlowAnalyzer.exitDelegateExpression(delegate)
|
||||
@@ -498,7 +506,7 @@ open class FirDeclarationsResolveTransformer(
|
||||
val hadExplicitType = variable.returnTypeRef !is FirImplicitTypeRef
|
||||
|
||||
if (delegate != null) {
|
||||
transformPropertyAccessorsWithDelegate(variable, delegate)
|
||||
transformPropertyAccessorsWithDelegate(variable, delegate, shouldResolveEverything = true)
|
||||
if (variable.delegateFieldSymbol != null) {
|
||||
replacePropertyReferenceTypeInDelegateAccessors(variable)
|
||||
}
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// IGNORE_REVERSED_RESOLVE
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@get:Anno(<!ANNOTATION_ARGUMENT_MUST_BE_CONST, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>foo<!>)
|
||||
@set:Anno(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>foo<!>)
|
||||
@setparam:Anno(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>foo<!>)
|
||||
@delegate:Anno(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>foo<!>)
|
||||
var foo by MyDelegate()
|
||||
|
||||
@Repeatable
|
||||
annotation class Anno(val i: Int)
|
||||
|
||||
class MyDelegate {
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>) = 42
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// IGNORE_REVERSED_RESOLVE
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@get:Anno(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>foo<!>)
|
||||
|
||||
Reference in New Issue
Block a user