Support decapitilized obsolete annotations in resolve
Annotations like `deprecated`, `jvmStatic`, etc. has been renamed to capitilized themselves. But we're going to support both versions. It's hard just to leave both versions of classes as their class-files can clash when compiled on register-independent file system. So here is solution (temporary hack): we just wrap JetScopes for package fragments of `kotlin.*` to make them search both versions of annotations if their names are contained in our hardcoded set.
This commit is contained in:
+1
-1
@@ -51,7 +51,7 @@ public class LazyJavaPackageFragmentProvider(
|
||||
override fun getPackageFragments(fqName: FqName) = emptyOrSingletonList(getPackageFragment(fqName))
|
||||
|
||||
override fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean) =
|
||||
getPackageFragment(fqName)?.getMemberScope()?.getSubPackages().orEmpty()
|
||||
getPackageFragment(fqName)?.scope?.getSubPackages().orEmpty()
|
||||
|
||||
fun getClass(javaClass: JavaClass): ClassDescriptor? = c.javaClassResolver.resolveClass(javaClass)
|
||||
|
||||
|
||||
+6
-2
@@ -22,12 +22,16 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
|
||||
class LazyJavaPackageFragment(
|
||||
private val c: LazyJavaResolverContext,
|
||||
private val jPackage: JavaPackage
|
||||
) : PackageFragmentDescriptorImpl(c.module, jPackage.getFqName()) {
|
||||
private val scope by lazy { LazyJavaPackageScope(c, jPackage, this) }
|
||||
val scope: LazyJavaPackageScope by lazy { LazyJavaPackageScope(c, jPackage, this) }
|
||||
// Just a temporary hack to inject deprecated decapitalized annotation
|
||||
private val wrappedScope by lazy { DecapitalizedAnnotationScope.wrapIfNeeded(scope, jPackage.getFqName()) }
|
||||
|
||||
private val topLevelClasses = c.storageManager.createMemoizedFunctionWithNullableValues {
|
||||
javaClass: JavaClass ->
|
||||
@@ -36,7 +40,7 @@ class LazyJavaPackageFragment(
|
||||
|
||||
internal fun resolveTopLevelClass(javaClass: JavaClass) = topLevelClasses(javaClass)
|
||||
|
||||
override fun getMemberScope() = scope
|
||||
override fun getMemberScope(): JetScope = wrappedScope
|
||||
|
||||
override fun toString() = "lazy java package fragment: $fqName"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user