mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 15:06:56 +07:00
[kotlin] Don't run module accessibility checker for internal visibility conflicts
The visibility conflict checker can already find such conflicts. #KTIJ-30460 Fixed GitOrigin-RevId: f2f10cfd2531e2fff5af5493547a084c803c9006
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8a841d4f84
commit
6c58aa0e5a
@@ -0,0 +1,2 @@
|
||||
File internalSource.kt uses property internalTargetVal which will be inaccessible after move
|
||||
Property sourceVal uses property internalTargetVal which will be inaccessible after move
|
||||
@@ -1,2 +1,2 @@
|
||||
Property a1.internalTargetVal, referenced in file internalSource.kt, will not be accessible from module A
|
||||
Property a1.internalTargetVal, referenced in property a2.sourceVal, will not be accessible from module A
|
||||
Property a1.internalTargetVal, referenced in property a2.sourceVal, will not be accessible from module A
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
"targetDirectory": "B/src/b",
|
||||
"withRuntime": "true",
|
||||
"enabledInK1": "true",
|
||||
"enabledInK2": "false"
|
||||
"enabledInK2": "true"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Class packA1.InternalContent, referenced in file InternalSource.kt, will not be accessible from module A
|
||||
Class packA1.InternalContent, referenced in function InternalContentUser.useInternal(InternalContent), will not be accessible from module A
|
||||
Class packA2.InternalContentUser, referenced in function InternalContent.useInternal(), will not be accessible in module B
|
||||
Function useInternal() uses function internalFunUser() which will be inaccessible after move
|
||||
Function useInternal(InternalContent) uses function internalFun() which will be inaccessible after move
|
||||
@@ -1,2 +1 @@
|
||||
File internalSource.kt uses property internalTargetVal which will be inaccessible after move
|
||||
Property a1.internalTargetVal, referenced in file internalSource.kt, will not be accessible from module A
|
||||
File internalSource.kt uses property internalTargetVal which will be inaccessible after move
|
||||
|
||||
@@ -1 +1 @@
|
||||
Property a1.internalTargetVal, referenced in file internalSource.kt, will not be accessible from module A
|
||||
Property a1.internalTargetVal, referenced in file internalSource.kt, will not be accessible from module A
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.asJava.toLightElements
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.base.util.quoteIfNeeded
|
||||
import org.jetbrains.kotlin.idea.codeinsight.utils.toVisibility
|
||||
import org.jetbrains.kotlin.idea.k2.refactoring.move.processor.K2MoveRenameUsageInfo.Companion.internalUsageInfo
|
||||
import org.jetbrains.kotlin.idea.refactoring.getContainer
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
@@ -36,6 +37,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClass
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
||||
import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierTypeOrDefault
|
||||
import org.jetbrains.kotlin.resolve.calls.util.getCalleeExpressionIfAny
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
|
||||
|
||||
@@ -143,6 +145,8 @@ private fun MoveRenameUsageInfo.willNotBeMoved(declarationsToMove: Set<KtNamedDe
|
||||
return this !is K2MoveRenameUsageInfo || !element.willBeMoved(declarationsToMove)
|
||||
}
|
||||
|
||||
private val KtNamedDeclaration.isInternal get() = visibilityModifierTypeOrDefault().toVisibility() == Visibilities.Internal
|
||||
|
||||
private fun PsiElement.createVisibilityConflict(referencedDeclaration: PsiElement): Pair<PsiElement, String> {
|
||||
return this to KotlinBundle.message(
|
||||
"text.0.uses.1.which.will.be.inaccessible.after.move",
|
||||
@@ -329,6 +333,7 @@ private fun checkModuleDependencyConflictsForNonMovedUsages(
|
||||
tryFindConflict {
|
||||
val usageElement = usage.element ?: return@tryFindConflict null
|
||||
val referencedDeclaration = usage.upToDateReferencedElement as? KtNamedDeclaration ?: return@tryFindConflict null
|
||||
if (referencedDeclaration.isInternal) return@tryFindConflict null
|
||||
val declarationCopy = containingCopyDecl(referencedDeclaration, oldToNewMap) ?: return@tryFindConflict null
|
||||
val targetModule = declarationCopy.containingModule() ?: return@tryFindConflict null
|
||||
val resolveScope = usageElement.resolveScope
|
||||
@@ -350,6 +355,7 @@ fun checkModuleDependencyConflictsForInternalUsages(
|
||||
tryFindConflict {
|
||||
val usageElement = usageInfo.element ?: return@tryFindConflict null
|
||||
val referencedDeclaration = usageInfo.upToDateReferencedElement as? PsiNamedElement ?: return@tryFindConflict null
|
||||
if (referencedDeclaration is KtNamedDeclaration && referencedDeclaration.isInternal) return@tryFindConflict null
|
||||
analyzeCopy(refExprCopy, KaDanglingFileResolutionMode.PREFER_SELF) {
|
||||
if (refExprCopy.mainReference.resolveToSymbol() == null) {
|
||||
val module = refExprCopy.containingModule() ?: return@analyzeCopy null
|
||||
|
||||
Reference in New Issue
Block a user