K1: don't filter Enum.entries in tower to report error later
After this commit we: - preserve Enum.entries synthetic property in tower even in case the bound feature is OFF - report an error on Enum.entries call in specific checker if the feature is OFF - give this synthetic property lower priority, no matter feature ON or OFF #KT-55251 Fixed
This commit is contained in:
committed by
Space Team
parent
793df6234e
commit
565adf3075
+5
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||
import org.jetbrains.kotlin.resolve.calls.components.candidate.CallableReferenceResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserveCompatibility
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
@@ -117,6 +118,10 @@ class CallableReferencesCandidateFactory(
|
||||
return createCallableReferenceCallCandidate(listOf(NotCallableMemberReference(kotlinCall, candidateDescriptor)))
|
||||
}
|
||||
|
||||
if (candidateDescriptor is PropertyDescriptor && candidateDescriptor.isSyntheticEnumEntries()) {
|
||||
diagnostics.add(LowerPriorityToPreserveCompatibility(needToReportWarning = false).asDiagnostic())
|
||||
}
|
||||
|
||||
diagnostics.addAll(towerCandidate.diagnostics)
|
||||
// todo smartcast on receiver diagnostic and CheckInstantiationOfAbstractClass
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstituto
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserveCompatibility
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateFactory
|
||||
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
+17
-3
@@ -6,6 +6,9 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.model
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
|
||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
|
||||
import org.jetbrains.kotlin.resolve.calls.components.NewConstraintSystemImpl
|
||||
@@ -13,13 +16,14 @@ import org.jetbrains.kotlin.resolve.calls.components.candidate.SimpleErrorResolu
|
||||
import org.jetbrains.kotlin.resolve.calls.components.candidate.SimpleResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemFromArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserveCompatibility
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDynamicExtensionAnnotation
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.error.ErrorScopeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
|
||||
class SimpleCandidateFactory(
|
||||
@@ -97,10 +101,15 @@ class SimpleCandidateFactory(
|
||||
)
|
||||
val extensionArgumentReceiver =
|
||||
createReceiverArgument(kotlinCall.getExplicitExtensionReceiver(explicitReceiverKind), extensionReceiver)
|
||||
val descriptor = towerCandidate.descriptor
|
||||
var diagnostics: List<KotlinCallDiagnostic> = towerCandidate.diagnostics
|
||||
if (descriptor is PropertyDescriptor && descriptor.isSyntheticEnumEntries()) {
|
||||
diagnostics = diagnostics + LowerPriorityToPreserveCompatibility(needToReportWarning = false).asDiagnostic()
|
||||
}
|
||||
|
||||
return createCandidate(
|
||||
towerCandidate.descriptor, explicitReceiverKind, dispatchArgumentReceiver,
|
||||
extensionArgumentReceiver, null, towerCandidate.diagnostics, knownSubstitutor = null
|
||||
descriptor, explicitReceiverKind, dispatchArgumentReceiver,
|
||||
extensionArgumentReceiver, extensionArgumentReceiverCandidates = null, diagnostics, knownSubstitutor = null
|
||||
)
|
||||
}
|
||||
|
||||
@@ -180,4 +189,9 @@ class SimpleCandidateFactory(
|
||||
extensionArgumentReceiverCandidates = null, initialDiagnostics = listOf(), knownSubstitutor = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun PropertyDescriptor.isSyntheticEnumEntries(): Boolean {
|
||||
return isSynthesized && dispatchReceiverParameter == null && extensionReceiverParameter == null &&
|
||||
(containingDeclaration as? ClassDescriptor)?.kind == ClassKind.ENUM_CLASS
|
||||
}
|
||||
Reference in New Issue
Block a user