Move AssertInvisibleInResolver check to frontend.java
This is a dirty hack, taking advantage of the fact that JavaResolverCache.getClass() is called exactly once and right after this check
This commit is contained in:
+19
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.java.resolver;
|
package org.jetbrains.jet.lang.resolve.java.resolver;
|
||||||
|
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.psi.PsiExpression;
|
import com.intellij.psi.PsiExpression;
|
||||||
import com.intellij.psi.PsiField;
|
import com.intellij.psi.PsiField;
|
||||||
import com.intellij.psi.PsiLiteralExpression;
|
import com.intellij.psi.PsiLiteralExpression;
|
||||||
@@ -37,12 +39,18 @@ import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementImpl;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaFieldImpl;
|
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaFieldImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaMethodImpl;
|
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaMethodImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
|
import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||||
|
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
||||||
|
|
||||||
public class TraceBasedJavaResolverCache implements JavaResolverCache {
|
public class TraceBasedJavaResolverCache implements JavaResolverCache {
|
||||||
|
private static final Logger LOG = Logger.getInstance(TraceBasedJavaResolverCache.class);
|
||||||
|
private static final FqName ASSERT_INVISIBLE_IN_RESOLVER_ANNOTATION = fqNameByClass(AssertInvisibleInResolver.class);
|
||||||
|
|
||||||
private BindingTrace trace;
|
private BindingTrace trace;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -77,6 +85,17 @@ public class TraceBasedJavaResolverCache implements JavaResolverCache {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor getClass(@NotNull JavaClass javaClass) {
|
public ClassDescriptor getClass(@NotNull JavaClass javaClass) {
|
||||||
|
FqName fqName = javaClass.getFqName();
|
||||||
|
if (fqName != null && KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(fqName.parent())) {
|
||||||
|
if (javaClass.findAnnotation(ASSERT_INVISIBLE_IN_RESOLVER_ANNOTATION) != null) {
|
||||||
|
if (ApplicationManager.getApplication().isInternal()) {
|
||||||
|
LOG.error("Classpath is configured incorrectly:" +
|
||||||
|
" class " + fqName + " from runtime must not be loaded by compiler");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return trace.get(CLASS, ((JavaClassImpl) javaClass).getPsi());
|
return trace.get(CLASS, ((JavaClassImpl) javaClass).getPsi());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-17
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.java.resolver;
|
package org.jetbrains.jet.lang.resolve.java.resolver;
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -47,19 +45,14 @@ import org.jetbrains.jet.lang.types.JetType;
|
|||||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getClassObjectName;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getClassObjectName;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule.INCLUDE_KOTLIN_SOURCES;
|
import static org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule.INCLUDE_KOTLIN_SOURCES;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
|
||||||
|
|
||||||
public final class JavaClassResolver {
|
public final class JavaClassResolver {
|
||||||
private static final FqName ASSERT_INVISIBLE_IN_RESOLVER_ANNOTATION = fqNameByClass(AssertInvisibleInResolver.class);
|
|
||||||
private static final Logger LOG = Logger.getInstance(JavaClassResolver.class);
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Map<FqNameUnsafe, ClassDescriptor> classDescriptorCache = new HashMap<FqNameUnsafe, ClassDescriptor>();
|
private final Map<FqNameUnsafe, ClassDescriptor> classDescriptorCache = new HashMap<FqNameUnsafe, ClassDescriptor>();
|
||||||
|
|
||||||
@@ -208,16 +201,6 @@ public final class JavaClassResolver {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(qualifiedName.parent())) {
|
|
||||||
if (javaClass.findAnnotation(ASSERT_INVISIBLE_IN_RESOLVER_ANNOTATION) != null) {
|
|
||||||
if (ApplicationManager.getApplication().isInternal()) {
|
|
||||||
LOG.error("classpath is configured incorrectly:" +
|
|
||||||
" class " + qualifiedName + " from runtime must not be loaded by compiler");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Class may have been resolved previously by different Java resolver instance, and we are reusing its trace
|
// Class may have been resolved previously by different Java resolver instance, and we are reusing its trace
|
||||||
ClassDescriptor alreadyResolved = cache.getClass(javaClass);
|
ClassDescriptor alreadyResolved = cache.getClass(javaClass);
|
||||||
if (alreadyResolved != null) {
|
if (alreadyResolved != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user