Deprecate visibility of static members inherited from Java
Now they are not visible by short name through companion objects, just like classifiers in KT-21515 ^KT-25333 In progress
This commit is contained in:
committed by
Dmitry Savvinov
parent
63202fe560
commit
76c651421b
@@ -222,13 +222,20 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
||||
private val resolutionScope: ResolutionScope
|
||||
) : AbstractScopeTowerLevel(scopeTower) {
|
||||
|
||||
val deprecationDiagnosticOfThisScope: ResolutionDiagnostic? =
|
||||
if (resolutionScope is DeprecatedLexicalScope) ResolvedUsingDeprecatedVisibility(resolutionScope, location) else null
|
||||
|
||||
internal constructor(scopeTower: ImplicitScopeTower, lexicalScope: LexicalScope) : this(scopeTower, lexicalScope as ResolutionScope)
|
||||
|
||||
override fun getVariables(
|
||||
name: Name,
|
||||
extensionReceiver: ReceiverValueWithSmartCastInfo?
|
||||
): Collection<CandidateWithBoundDispatchReceiver> = resolutionScope.getContributedVariables(name, location).map {
|
||||
createCandidateDescriptor(it, dispatchReceiver = null)
|
||||
createCandidateDescriptor(
|
||||
it,
|
||||
dispatchReceiver = null,
|
||||
specialError = deprecationDiagnosticOfThisScope
|
||||
)
|
||||
}
|
||||
|
||||
override fun getObjects(
|
||||
@@ -249,8 +256,13 @@ internal open class ScopeBasedTowerLevel protected constructor(
|
||||
): Collection<CandidateWithBoundDispatchReceiver> {
|
||||
val result: ArrayList<CandidateWithBoundDispatchReceiver> = ArrayList()
|
||||
|
||||
resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticScopes)
|
||||
.mapTo(result) { createCandidateDescriptor(it, dispatchReceiver = null) }
|
||||
resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticScopes).mapTo(result) {
|
||||
createCandidateDescriptor(
|
||||
it,
|
||||
dispatchReceiver = null,
|
||||
specialError = deprecationDiagnosticOfThisScope
|
||||
)
|
||||
}
|
||||
|
||||
// Add constructors of deprecated classifier with an additional diagnostic
|
||||
val descriptorWithDeprecation = resolutionScope.getContributedClassifierIncludeDeprecated(name, location)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes.utils
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -91,8 +92,20 @@ fun DeclarationDescriptor.canBeResolvedWithoutDeprecation(
|
||||
location: LookupLocation
|
||||
): Boolean {
|
||||
for (scope in scopeForResolution.parentsWithSelf) {
|
||||
val (descriptorFromCurrentScope, isDeprecated) = scope.getContributedClassifierIncludeDeprecated(name, location) ?: continue
|
||||
if (descriptorFromCurrentScope == this && !isDeprecated) return true
|
||||
val hasNonDeprecatedSuitableCandidate = when (this) {
|
||||
// Looking for classifier: fair check via special method in ResolutionScope
|
||||
is ClassifierDescriptor -> scope.getContributedClassifierIncludeDeprecated(name, location)
|
||||
?.let { it.descriptor == this && !it.isDeprecated }
|
||||
|
||||
// Looking for member: heuristically check only one case, when another descriptor visible through explicit import
|
||||
is VariableDescriptor -> (scope as? ImportingScope)?.getContributedVariables(name, location)?.any { it == this }
|
||||
|
||||
is FunctionDescriptor -> (scope as? ImportingScope)?.getContributedFunctions(name, location)?.any { it == this }
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (hasNonDeprecatedSuitableCandidate == true) return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user