Add new 'HiddenInResolution' kind
It's used to hide additional built-ins members loaded from JDK Such methods can be overridden and called only with 'super'-receiver
This commit is contained in:
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
@@ -46,6 +47,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : SyntheticScope
|
||||
if (!function.hasJavaOriginInHierarchy()) return null //TODO: should we go into base at all?
|
||||
if (!SingleAbstractMethodUtils.isSamAdapterNecessary(function)) return null
|
||||
if (function.returnType == null) return null
|
||||
if (function.isHiddenInResolution()) return null
|
||||
return MyFunctionDescriptor.create(function)
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -171,7 +171,7 @@ class NewResolutionOldInference(
|
||||
val candidateTrace = TemporaryBindingTrace.create(basicCallContext.trace, "Context for resolve candidate")
|
||||
val resolvedCall = ResolvedCallImpl.create(candidate, candidateTrace, tracing, basicCallContext.dataFlowInfoForArguments)
|
||||
|
||||
if (candidate.descriptor.isHiddenInResolution()) {
|
||||
if (candidate.descriptor.isHiddenInResolution(basicCallContext.isSuperCall)) {
|
||||
return@mapNotNull MyCandidate(ResolutionCandidateStatus(listOf(HiddenDescriptor)), resolvedCall)
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ class NewResolutionOldInference(
|
||||
return MyCandidate(ResolutionCandidateStatus(listOf(ExtensionWithStaticTypeWithDynamicReceiver)), candidateCall)
|
||||
}
|
||||
|
||||
if (towerCandidate.descriptor.isHiddenInResolution()) {
|
||||
if (towerCandidate.descriptor.isHiddenInResolution(basicCallContext.isSuperCall)) {
|
||||
return MyCandidate(ResolutionCandidateStatus(listOf(HiddenDescriptor)), candidateCall)
|
||||
}
|
||||
|
||||
@@ -424,4 +424,6 @@ internal fun createPreviousResolveError(status: ResolutionStatus): PreviousResol
|
||||
else -> ResolutionCandidateApplicability.INAPPLICABLE
|
||||
}
|
||||
return PreviousResolutionError(level)
|
||||
}
|
||||
}
|
||||
|
||||
private val BasicCallResolutionContext.isSuperCall: Boolean get() = call.explicitReceiver is SuperCallReceiverValue
|
||||
|
||||
@@ -178,7 +178,11 @@ enum class DeprecationLevelValue {
|
||||
WARNING, ERROR, HIDDEN
|
||||
}
|
||||
|
||||
fun DeclarationDescriptor.isHiddenInResolution(): Boolean {
|
||||
if (this is FunctionDescriptor && this.isHiddenToOvercomeSignatureClash) return true
|
||||
@JvmOverloads
|
||||
fun DeclarationDescriptor.isHiddenInResolution(isSuperCall: Boolean = false): Boolean {
|
||||
if (this is FunctionDescriptor) {
|
||||
if (isHiddenToOvercomeSignatureClash) return true
|
||||
if (isHiddenForResolutionEverywhereBesideSupercalls && !isSuperCall) return true
|
||||
}
|
||||
return getDeprecation()?.deprecationLevel == DeprecationLevelValue.HIDDEN
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user