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:
@@ -138,7 +138,7 @@ public class JvmCodegenUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
KotlinJvmBinaryClass binaryClass = ((LazyJavaPackageFragment) packageFragment).getMemberScope().getKotlinBinaryClass();
|
||||
KotlinJvmBinaryClass binaryClass = ((LazyJavaPackageFragment) packageFragment).getScope().getKotlinBinaryClass();
|
||||
if (binaryClass instanceof VirtualFileKotlinClass) {
|
||||
VirtualFile file = ((VirtualFileKotlinClass) binaryClass).getFile();
|
||||
if (file.getFileSystem().getProtocol() == StandardFileSystems.FILE_PROTOCOL) {
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.serialization.PackageData
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
@@ -105,7 +106,7 @@ public class IncrementalPackageFragmentProvider(
|
||||
JetScope.Empty
|
||||
}
|
||||
else {
|
||||
IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(packageDataBytes))
|
||||
DecapitalizedAnnotationScope.wrapIfNeeded(IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(packageDataBytes)), fqName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.PackageMemberDeclarationProvider;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
|
||||
public class LazyPackageDescriptor extends PackageFragmentDescriptorImpl implements LazyEntity {
|
||||
@@ -41,7 +42,8 @@ public class LazyPackageDescriptor extends PackageFragmentDescriptorImpl impleme
|
||||
super(module, fqName);
|
||||
this.declarationProvider = declarationProvider;
|
||||
|
||||
this.memberScope = new LazyPackageMemberScope(resolveSession, declarationProvider, this);
|
||||
// Wrapping is just a temporary hack to inject deprecated decapitalized annotation
|
||||
this.memberScope = DecapitalizedAnnotationScope.Companion.wrapIfNeeded(new LazyPackageMemberScope(resolveSession, declarationProvider, this), fqName);
|
||||
|
||||
for (JetFile file : declarationProvider.getPackageFiles()) {
|
||||
resolveSession.getTrace().record(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file, this);
|
||||
|
||||
Reference in New Issue
Block a user