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:
+11
-2
@@ -20,6 +20,8 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.SerializedResourcePaths
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||
@@ -56,10 +58,17 @@ public abstract class DeserializedPackageFragment(
|
||||
DeserializedPackageMemberScope(this, packageProto, nameResolver, components, classNames = { loadClassNames(packageProto) })
|
||||
}
|
||||
|
||||
override fun getMemberScope() = deserializedMemberScope
|
||||
// Just a temporary hack to inject deprecated decapitalized annotation
|
||||
internal val deserializedMemberScopeWrapped by storageManager.createLazyValue {
|
||||
DecapitalizedAnnotationScope.wrapIfNeeded(deserializedMemberScope, fqName)
|
||||
}
|
||||
|
||||
override fun getMemberScope(): JetScope {
|
||||
return deserializedMemberScopeWrapped
|
||||
}
|
||||
|
||||
internal fun hasTopLevelClass(name: Name): Boolean {
|
||||
return name in getMemberScope().classNames
|
||||
return name in deserializedMemberScope.classNames
|
||||
}
|
||||
|
||||
protected abstract fun loadClassNames(packageProto: ProtoBuf.Package): Collection<Name>
|
||||
|
||||
Reference in New Issue
Block a user