diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java index 5a0d5d17f80..938d0386689 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java @@ -33,10 +33,7 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; -import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants; -import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; -import org.jetbrains.jet.lang.resolve.java.JvmAbi; -import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType; +import org.jetbrains.jet.lang.resolve.java.*; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lexer.JetTokens; @@ -551,7 +548,7 @@ public class AsmUtil { private static boolean isDeclaredInJava(@NotNull CallableDescriptor callableDescriptor, @NotNull BindingContext context) { CallableDescriptor descriptor = callableDescriptor; while (true) { - if (Boolean.TRUE.equals(context.get(BindingContext.IS_DECLARED_IN_JAVA, descriptor))) { + if (Boolean.TRUE.equals(context.get(JavaBindingContext.IS_DECLARED_IN_JAVA, descriptor))) { return true; } CallableDescriptor original = descriptor.getOriginal(); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 30e07e84db9..3307ddd9717 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -50,10 +50,7 @@ import org.jetbrains.jet.lang.resolve.calls.model.*; import org.jetbrains.jet.lang.resolve.calls.util.CallMaker; import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; -import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants; -import org.jetbrains.jet.lang.resolve.java.JvmAbi; -import org.jetbrains.jet.lang.resolve.java.JvmClassName; -import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType; +import org.jetbrains.jet.lang.resolve.java.*; import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode; import org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils; import org.jetbrains.jet.lang.resolve.name.Name; @@ -1880,7 +1877,7 @@ public class ExpressionCodegen extends JetVisitor implem if (funDescriptor instanceof SimpleFunctionDescriptor) { ClassDescriptor samInterface = bindingContext.get( - BindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal()); + JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal()); if (samInterface != null) { return invokeSamConstructor(expression, resolvedCall, (ClassDescriptorFromJvmBytecode) samInterface); @@ -1897,7 +1894,7 @@ public class ExpressionCodegen extends JetVisitor implem } FunctionDescriptor original = ((FunctionDescriptor) fun).getOriginal(); if (original.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) { - return bindingContext.get(SAM_ADAPTER_FUNCTION_TO_ORIGINAL, original); + return bindingContext.get(JavaBindingContext.SAM_ADAPTER_FUNCTION_TO_ORIGINAL, original); } if (original.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { for (FunctionDescriptor overridden : original.getOverriddenDescriptors()) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java index b91bf08e7d7..fa084997be3 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java @@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; +import org.jetbrains.jet.lang.resolve.java.JavaBindingContext; import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.java.JvmClassName; import org.jetbrains.jet.lang.resolve.java.PackageClassUtils; @@ -73,7 +74,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { if (funDescriptor instanceof SimpleFunctionDescriptor) { ClassDescriptor samTrait = bindingContext.get( - BindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal()); + JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal()); if (samTrait != null) { String name = inventAnonymousClassName(expression); bindingTrace.record(FQN_FOR_SAM_CONSTRUCTOR, expression, JvmClassName.byInternalName(name)); diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java b/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java index 6e6092088cd..6ec5b9678bd 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java @@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.java.AbiVersionUtil; +import org.jetbrains.jet.lang.resolve.java.JavaBindingContext; import org.jetbrains.jet.lang.resolve.java.JvmAbi; import java.util.Collection; @@ -119,14 +120,14 @@ public final class AnalyzerWithCompilerReport { private void reportAlternativeSignatureErrors() { assert analyzeExhaust != null; BindingContext bc = analyzeExhaust.getBindingContext(); - Collection descriptorsWithErrors = bc.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS); + Collection descriptorsWithErrors = bc.getKeys(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS); if (!descriptorsWithErrors.isEmpty()) { StringBuilder message = new StringBuilder("The following Java entities have annotations with wrong Kotlin signatures:\n"); for (DeclarationDescriptor descriptor : descriptorsWithErrors) { PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bc, descriptor); assert declaration instanceof PsiModifierListOwner; - List errors = bc.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor); + List errors = bc.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor); assert errors != null && !errors.isEmpty(); String externalName = PsiFormatUtil.getExternalName((PsiModifierListOwner) declaration); diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java index fb6c5b34da9..f243ed62c9e 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java @@ -16,11 +16,14 @@ package org.jetbrains.jet.lang.resolve.java; -import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.util.slicedmap.BasicWritableSlice; import org.jetbrains.jet.util.slicedmap.Slices; import org.jetbrains.jet.util.slicedmap.WritableSlice; +import java.util.List; + /** * @see BindingContext */ @@ -32,6 +35,14 @@ public class JavaBindingContext { public static final WritableSlice JAVA_NAMESPACE_KIND = Slices.createSimpleSlice(); + public static final WritableSlice> LOAD_FROM_JAVA_SIGNATURE_ERRORS = + new BasicWritableSlice>(Slices.ONLY_REWRITE_TO_EQUAL, true); + + public static final WritableSlice IS_DECLARED_IN_JAVA = Slices.createSimpleSlice(); + + public static final WritableSlice SAM_CONSTRUCTOR_TO_INTERFACE = Slices.createSimpleSlice(); + public static final WritableSlice SAM_ADAPTER_FUNCTION_TO_ORIGINAL = Slices.createSimpleSlice(); + private JavaBindingContext() { } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java index eb9d0d20bf8..00e6f40e468 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java @@ -213,7 +213,7 @@ public final class JavaConstructorResolver { valueParameterDescriptors = alternativeMethodSignatureData.getValueParameters(); } else if (alternativeMethodSignatureData.hasErrors()) { - trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, constructorDescriptor, + trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, constructorDescriptor, Collections.singletonList(alternativeMethodSignatureData.getError())); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java index d2541fe1f5b..7f01b33c5b3 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java @@ -201,7 +201,7 @@ public final class JavaFunctionResolver { } if (declarationOrigin == JAVA && record) { - trace.record(BindingContext.IS_DECLARED_IN_JAVA, functionDescriptorImpl); + trace.record(JavaBindingContext.IS_DECLARED_IN_JAVA, functionDescriptorImpl); } if (containingClass != psiClass && !method.isStatic()) { @@ -216,7 +216,7 @@ public final class JavaFunctionResolver { } else { if (record) { - trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, functionDescriptorImpl, signatureErrors); + trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, functionDescriptorImpl, signatureErrors); } } } @@ -493,13 +493,13 @@ public final class JavaFunctionResolver { } private static SimpleFunctionDescriptor recordSamConstructor(ClassDescriptor klass, SimpleFunctionDescriptor constructorFunction, BindingTrace trace) { - trace.record(BindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, constructorFunction, klass); + trace.record(JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, constructorFunction, klass); trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, constructorFunction, klass); return constructorFunction; } static F recordSamAdapter(F original, F adapterFunction, BindingTrace trace) { - trace.record(BindingContext.SAM_ADAPTER_FUNCTION_TO_ORIGINAL, adapterFunction, original); + trace.record(JavaBindingContext.SAM_ADAPTER_FUNCTION_TO_ORIGINAL, adapterFunction, original); trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, adapterFunction, original); return adapterFunction; } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java index 43bdd800784..9c9cf23d4bb 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java @@ -241,7 +241,7 @@ public final class JavaPropertyResolver { recordObjectDeclarationClassIfNeeded(psiData, owner, propertyDescriptor, propertyType); if (scopeData.getDeclarationOrigin() == JAVA) { - trace.record(BindingContext.IS_DECLARED_IN_JAVA, propertyDescriptor); + trace.record(JavaBindingContext.IS_DECLARED_IN_JAVA, propertyDescriptor); } return propertyDescriptor; } @@ -264,7 +264,7 @@ public final class JavaPropertyResolver { } } else { - trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, propertyDescriptor, + trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, propertyDescriptor, Collections.singletonList(signatureData.getError())); } return propertyType; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java index dbc1d85ee1d..1fce91e3081 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java @@ -260,12 +260,6 @@ public interface BindingContext { WritableSlice INCOMPLETE_HIERARCHY = Slices.createCollectiveSetSlice(); - WritableSlice> LOAD_FROM_JAVA_SIGNATURE_ERRORS = - new BasicWritableSlice>(Slices.ONLY_REWRITE_TO_EQUAL, true); - - WritableSlice IS_DECLARED_IN_JAVA = Slices.createSimpleSlice(); - WritableSlice SAM_CONSTRUCTOR_TO_INTERFACE = Slices.createSimpleSlice(); - WritableSlice SAM_ADAPTER_FUNCTION_TO_ORIGINAL = Slices.createSimpleSlice(); WritableSlice SOURCE_DESCRIPTOR_FOR_SYNTHESIZED = Slices.createSimpleSlice(); @SuppressWarnings("UnusedDeclaration") diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/ExpectedLoadErrorsUtil.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/ExpectedLoadErrorsUtil.java index 07c2b97aa3b..24f62696397 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/ExpectedLoadErrorsUtil.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/ExpectedLoadErrorsUtil.java @@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorVisitorEmpty import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.resolve.java.JavaBindingContext; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.renderer.DescriptorRenderer; @@ -114,9 +115,9 @@ public class ExpectedLoadErrorsUtil { private static Map> getActualLoadErrors(@NotNull BindingContext bindingContext) { Map> result = new HashMap>(); - Collection descriptors = bindingContext.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS); + Collection descriptors = bindingContext.getKeys(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS); for (DeclarationDescriptor descriptor : descriptors) { - List errors = bindingContext.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor); + List errors = bindingContext.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor); result.put(descriptor, errors); } diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/JdkAnnotationsValidityTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/JdkAnnotationsValidityTest.java index 1dd31921ecd..2999e7b5f02 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/JdkAnnotationsValidityTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/JdkAnnotationsValidityTest.java @@ -41,6 +41,7 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.resolve.java.JavaBindingContext; import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; import org.jetbrains.jet.lang.resolve.java.JavaToKotlinClassMap; import org.jetbrains.jet.lang.resolve.java.kotlinSignature.TypeTransformingVisitor; @@ -199,7 +200,7 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase { } private Void visitDeclaration(@NotNull DeclarationDescriptor descriptor) { - List errors = bindingContext.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor); + List errors = bindingContext.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor); if (errors != null) { this.errors.put(DescriptorRenderer.TEXT.render(descriptor), errors); } diff --git a/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java b/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java index 7209e3a414d..9e51cdd55a0 100644 --- a/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java @@ -39,6 +39,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; +import org.jetbrains.jet.lang.resolve.java.JavaBindingContext; import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; import org.jetbrains.jet.lang.resolve.java.scope.JavaClassNonStaticMembersScope; import org.jetbrains.jet.lang.resolve.name.FqName; @@ -101,7 +102,7 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider { if (memberDescriptor == null) continue; - List errors = trace.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, memberDescriptor); + List errors = trace.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, memberDescriptor); boolean hasSignatureAnnotation = KotlinSignatureUtil.findKotlinSignatureAnnotation(element) != null; if (errors != null || hasSignatureAnnotation) {