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:
Denis Zharkov
2015-09-04 12:24:42 +03:00
parent 31244edec9
commit 4159c83282
7 changed files with 86 additions and 8 deletions
@@ -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) {
@@ -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)
}
}
}
@@ -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);