Check type alias expansion for Java 9 module accessibility
#KT-18598 In Progress
This commit is contained in:
+15
-7
@@ -117,15 +117,23 @@ class JvmModuleAccessibilityChecker(project: Project) : CallChecker {
|
|||||||
element: PsiElement,
|
element: PsiElement,
|
||||||
languageVersionSettings: LanguageVersionSettings
|
languageVersionSettings: LanguageVersionSettings
|
||||||
) {
|
) {
|
||||||
val targetClassOrPackage = when (targetDescriptor) {
|
val virtualFile = element.containingFile.virtualFile
|
||||||
is ClassDescriptor -> targetDescriptor
|
when (targetDescriptor) {
|
||||||
is TypeAliasDescriptor -> {
|
is ClassDescriptor -> {
|
||||||
DescriptorUtils.getParentOfType(targetDescriptor, ClassOrPackageFragmentDescriptor::class.java) ?: return
|
diagnosticFor(targetDescriptor, targetDescriptor, virtualFile, element)?.let(trace::report)
|
||||||
}
|
}
|
||||||
else -> return
|
is TypeAliasDescriptor -> {
|
||||||
}
|
val containingClassOrPackage = DescriptorUtils.getParentOfType(targetDescriptor, ClassOrPackageFragmentDescriptor::class.java)
|
||||||
|
if (containingClassOrPackage != null) {
|
||||||
|
diagnosticFor(containingClassOrPackage, targetDescriptor, virtualFile, element)?.let(trace::report)
|
||||||
|
}
|
||||||
|
|
||||||
diagnosticFor(targetClassOrPackage, targetDescriptor, element.containingFile.virtualFile, element)?.let(trace::report)
|
val expandedClass = targetDescriptor.expandedType.constructor.declarationDescriptor as? ClassDescriptor
|
||||||
|
if (expandedClass != null) {
|
||||||
|
diagnosticFor(expandedClass, expandedClass, virtualFile, element)?.let(trace::report)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package exported
|
||||||
|
|
||||||
|
import unexported.*
|
||||||
|
|
||||||
|
typealias AliasToUnexported = Unexported
|
||||||
|
typealias AliasToListOfUnexported = List<AliasToUnexported>
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
module dependency {
|
||||||
|
exports exported;
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package unexported
|
||||||
|
|
||||||
|
class Unexported
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
module main {
|
||||||
|
requires dependency;
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
import exported.*
|
||||||
|
|
||||||
|
fun f1(): <error>AliasToUnexported</error>? = null
|
||||||
|
fun f2(): AliasToListOfUnexported? = null
|
||||||
+5
@@ -78,4 +78,9 @@ class Java9MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
|||||||
module("main").addDependency(module("dependency"))
|
module("main").addDependency(module("dependency"))
|
||||||
checkHighlightingInAllFiles()
|
checkHighlightingInAllFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testTypealiasToUnexported() = doTest {
|
||||||
|
module("main").addDependency(module("dependency"))
|
||||||
|
checkHighlightingInAllFiles()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user