From a17328f9d35f736d500a1c4650ec1f30bee840c6 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 21 Aug 2013 15:47:23 +0400 Subject: [PATCH] Minor, move ABI version error reporting AbiVersionUtil will be used in descriptors.loader.java, so it cannot depend on BindingTrace --- .../messages/AnalyzerWithCompilerReport.java | 9 ++--- .../jet/lang/resolve/java/AbiVersionUtil.java | 33 ------------------- .../resolver/TraceBasedErrorReporter.java | 30 +++++++++++++++-- 3 files changed, 33 insertions(+), 39 deletions(-) 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 0b3e8e5cce1..1af028ffdd3 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 @@ -35,9 +35,9 @@ import org.jetbrains.jet.lang.resolve.AnalyzingUtils; 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 org.jetbrains.jet.lang.resolve.java.resolver.TraceBasedErrorReporter; import java.util.Collection; import java.util.List; @@ -143,9 +143,10 @@ public final class AnalyzerWithCompilerReport { assert analyzeExhaust != null; BindingContext bindingContext = analyzeExhaust.getBindingContext(); - Collection errorLocations = bindingContext.getKeys(AbiVersionUtil.ABI_VERSION_ERRORS); - for (AbiVersionUtil.AbiVersionErrorLocation abiVersionErrorLocation : errorLocations) { - Integer abiVersion = bindingContext.get(AbiVersionUtil.ABI_VERSION_ERRORS, abiVersionErrorLocation); + Collection errorLocations = + bindingContext.getKeys(TraceBasedErrorReporter.ABI_VERSION_ERRORS); + for (TraceBasedErrorReporter.AbiVersionErrorLocation abiVersionErrorLocation : errorLocations) { + Integer abiVersion = bindingContext.get(TraceBasedErrorReporter.ABI_VERSION_ERRORS, abiVersionErrorLocation); messageCollectorWrapper.report(CompilerMessageSeverity.ERROR, "Class '" + abiVersionErrorLocation.getClassFqName().asString() + "' was compiled with an incompatible version of Kotlin. " + diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AbiVersionUtil.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AbiVersionUtil.java index 6e5dc734797..dea8acc2a17 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AbiVersionUtil.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AbiVersionUtil.java @@ -16,46 +16,13 @@ package org.jetbrains.jet.lang.resolve.java; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.resolve.BindingTrace; -import org.jetbrains.jet.lang.resolve.java.resolver.ErrorReporter; -import org.jetbrains.jet.lang.resolve.name.FqName; -import org.jetbrains.jet.util.slicedmap.BasicWritableSlice; -import org.jetbrains.jet.util.slicedmap.Slices; -import org.jetbrains.jet.util.slicedmap.WritableSlice; - public final class AbiVersionUtil { - public static final WritableSlice ABI_VERSION_ERRORS = - new BasicWritableSlice(Slices.ONLY_REWRITE_TO_EQUAL, true); public static final int INVALID_VERSION = -1; public static boolean isAbiVersionCompatible(int abiVersion) { return abiVersion == JvmAbi.VERSION; } - public static final class AbiVersionErrorLocation { - @NotNull - private final FqName classFqName; - @NotNull - private final VirtualFile file; - - public AbiVersionErrorLocation(@NotNull FqName name, @NotNull VirtualFile file) { - this.classFqName = name; - this.file = file; - } - - @NotNull - public FqName getClassFqName() { - return classFqName; - } - - @NotNull - public String getPath() { - return file.getPath(); - } - } - private AbiVersionUtil() { } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/TraceBasedErrorReporter.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/TraceBasedErrorReporter.java index 5490dea335d..b82c393ca7c 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/TraceBasedErrorReporter.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/TraceBasedErrorReporter.java @@ -19,12 +19,16 @@ package org.jetbrains.jet.lang.resolve.java.resolver; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.BindingTrace; -import org.jetbrains.jet.lang.resolve.java.AbiVersionUtil; import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.util.slicedmap.BasicWritableSlice; +import org.jetbrains.jet.util.slicedmap.Slices; +import org.jetbrains.jet.util.slicedmap.WritableSlice; import javax.inject.Inject; public class TraceBasedErrorReporter implements ErrorReporter { + public static final WritableSlice ABI_VERSION_ERRORS = + new BasicWritableSlice(Slices.ONLY_REWRITE_TO_EQUAL, true); private BindingTrace trace; @Inject @@ -34,6 +38,28 @@ public class TraceBasedErrorReporter implements ErrorReporter { @Override public void reportIncompatibleAbiVersion(@NotNull FqName fqName, @NotNull VirtualFile file, int actualVersion) { - trace.record(AbiVersionUtil.ABI_VERSION_ERRORS, new AbiVersionUtil.AbiVersionErrorLocation(fqName, file), actualVersion); + trace.record(ABI_VERSION_ERRORS, new AbiVersionErrorLocation(fqName, file), actualVersion); + } + + public static final class AbiVersionErrorLocation { + @NotNull + private final FqName classFqName; + @NotNull + private final VirtualFile file; + + public AbiVersionErrorLocation(@NotNull FqName name, @NotNull VirtualFile file) { + this.classFqName = name; + this.file = file; + } + + @NotNull + public FqName getClassFqName() { + return classFqName; + } + + @NotNull + public String getPath() { + return file.getPath(); + } } }