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,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
val targetClassOrPackage = when (targetDescriptor) {
|
||||
is ClassDescriptor -> targetDescriptor
|
||||
is TypeAliasDescriptor -> {
|
||||
DescriptorUtils.getParentOfType(targetDescriptor, ClassOrPackageFragmentDescriptor::class.java) ?: return
|
||||
val virtualFile = element.containingFile.virtualFile
|
||||
when (targetDescriptor) {
|
||||
is ClassDescriptor -> {
|
||||
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"))
|
||||
checkHighlightingInAllFiles()
|
||||
}
|
||||
|
||||
fun testTypealiasToUnexported() = doTest {
|
||||
module("main").addDependency(module("dependency"))
|
||||
checkHighlightingInAllFiles()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user