CLI: improve diagnostic message format

- render the whole line where the error/warning points to, if any, and another
  line with '^', like other compilers do
- lowercase diagnostic severity
- decapitalize the message if it doesn't start with a proper name
This commit is contained in:
Alexander Udalov
2015-06-13 03:43:20 +03:00
parent 46515afb22
commit 54dfd626ab
49 changed files with 316 additions and 134 deletions
@@ -21,15 +21,21 @@ import kotlin.platform.platformStatic
public data class CompilerMessageLocation private constructor( public data class CompilerMessageLocation private constructor(
public val path: String?, public val path: String?,
public val line: Int, public val line: Int,
public val column: Int public val column: Int,
public val lineContent: String?
) { ) {
override fun toString(): String = override fun toString(): String =
path + (if (line != -1 || column != -1) " (" + line + ":" + column + ")" else "") path + (if (line != -1 || column != -1) " (" + line + ":" + column + ")" else "")
companion object { companion object {
public platformStatic val NO_LOCATION: CompilerMessageLocation = CompilerMessageLocation(null, -1, -1) public platformStatic val NO_LOCATION: CompilerMessageLocation = CompilerMessageLocation(null, -1, -1, null)
public platformStatic fun create(path: String?, line: Int, column: Int): CompilerMessageLocation = public platformStatic fun create(
if (path == null) NO_LOCATION else CompilerMessageLocation(path, line, column) path: String?,
line: Int,
column: Int,
lineContent: String?
): CompilerMessageLocation =
if (path == null) NO_LOCATION else CompilerMessageLocation(path, line, column, lineContent)
} }
} }
@@ -17,6 +17,8 @@
package org.jetbrains.kotlin.cli.common.messages; package org.jetbrains.kotlin.cli.common.messages;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.LineSeparator;
import kotlin.KotlinPackage;
import kotlin.io.IoPackage; import kotlin.io.IoPackage;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -78,6 +80,8 @@ public interface MessageRenderer {
}; };
abstract class PlainText implements MessageRenderer { abstract class PlainText implements MessageRenderer {
private static final String LINE_SEPARATOR = LineSeparator.getSystemLineSeparator().getSeparatorString();
@Override @Override
public String renderPreamble() { public String renderPreamble() {
return ""; return "";
@@ -88,24 +92,56 @@ public interface MessageRenderer {
@NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location @NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location
) { ) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
result.append(severity).append(": ");
int line = location.getLine();
int column = location.getColumn();
String lineContent = location.getLineContent();
String path = getPath(location); String path = getPath(location);
if (path != null) { if (path != null) {
result.append(path); result.append(path);
result.append(": "); result.append(":");
if (location.getLine() > 0 && location.getColumn() > 0) { if (line > 0) {
result.append("("); result.append(line).append(":");
result.append(location.getLine()).append(", ").append(location.getColumn()); if (column > 0) {
result.append(") "); result.append(column).append(":");
}
} }
result.append(" ");
} }
result.append(message); result.append(severity.name().toLowerCase());
result.append(": ");
result.append(decapitalizeIfNeeded(message));
if (lineContent != null && 1 <= column && column <= lineContent.length() + 1) {
result.append(LINE_SEPARATOR);
result.append(lineContent);
result.append(LINE_SEPARATOR);
result.append(KotlinPackage.repeat(" ", column - 1));
result.append("^");
}
return result.toString(); return result.toString();
} }
@NotNull
private static String decapitalizeIfNeeded(@NotNull String message) {
// TODO: invent something more clever
// An ad-hoc heuristic to prevent decapitalization of some names
if (message.startsWith("Java") || message.startsWith("Kotlin")) {
return message;
}
// For abbreviations and capitalized text
if (message.length() >= 2 && Character.isUpperCase(message.charAt(0)) && Character.isUpperCase(message.charAt(1))) {
return message;
}
return KotlinPackage.decapitalize(message);
}
@Nullable @Nullable
protected abstract String getPath(@NotNull CompilerMessageLocation location); protected abstract String getPath(@NotNull CompilerMessageLocation location);
@@ -73,17 +73,22 @@ public final class AnalyzerWithCompilerReport {
private static boolean reportDiagnostic(@NotNull Diagnostic diagnostic, @NotNull MessageCollector messageCollector) { private static boolean reportDiagnostic(@NotNull Diagnostic diagnostic, @NotNull MessageCollector messageCollector) {
if (!diagnostic.isValid()) return false; if (!diagnostic.isValid()) return false;
DiagnosticUtils.LineAndColumn lineAndColumn = DiagnosticUtils.getLineAndColumn(diagnostic);
String render; String render;
if (diagnostic instanceof MyDiagnostic) { if (diagnostic instanceof MyDiagnostic) {
render = ((MyDiagnostic)diagnostic).message; render = ((MyDiagnostic) diagnostic).message;
} }
else { else {
render = DefaultErrorMessages.render(diagnostic); render = DefaultErrorMessages.render(diagnostic);
} }
PsiFile file = diagnostic.getPsiFile(); PsiFile file = diagnostic.getPsiFile();
messageCollector.report(convertSeverity(diagnostic.getSeverity()), render, messageCollector.report(
MessageUtil.psiFileToMessageLocation(file, file.getName(), lineAndColumn.getLine(), lineAndColumn.getColumn())); convertSeverity(diagnostic.getSeverity()),
render,
MessageUtil.psiFileToMessageLocation(file, file.getName(), DiagnosticUtils.getLineAndColumn(diagnostic))
);
return diagnostic.getSeverity() == Severity.ERROR; return diagnostic.getSeverity() == Severity.ERROR;
} }
@@ -141,7 +146,7 @@ public final class AnalyzerWithCompilerReport {
CompilerMessageSeverity.ERROR, CompilerMessageSeverity.ERROR,
"Class '" + JvmClassName.byClassId(data.getClassId()) + "' was compiled with an incompatible version of Kotlin. " + "Class '" + JvmClassName.byClassId(data.getClassId()) + "' was compiled with an incompatible version of Kotlin. " +
"Its ABI version is " + data.getActualVersion() + ", expected ABI version is " + JvmAbi.VERSION, "Its ABI version is " + data.getActualVersion() + ", expected ABI version is " + JvmAbi.VERSION,
CompilerMessageLocation.create(path, -1, -1) CompilerMessageLocation.create(path, -1, -1, null)
); );
} }
} }
@@ -33,12 +33,15 @@ public class MessageUtil {
@NotNull @NotNull
public static CompilerMessageLocation psiElementToMessageLocation(@NotNull PsiElement element) { public static CompilerMessageLocation psiElementToMessageLocation(@NotNull PsiElement element) {
PsiFile file = element.getContainingFile(); PsiFile file = element.getContainingFile();
DiagnosticUtils.LineAndColumn lineAndColumn = DiagnosticUtils.getLineAndColumnInPsiFile(file, element.getTextRange()); return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnInPsiFile(file, element.getTextRange()));
return psiFileToMessageLocation(file, "<no path>", lineAndColumn.getLine(), lineAndColumn.getColumn());
} }
@NotNull @NotNull
public static CompilerMessageLocation psiFileToMessageLocation(@NotNull PsiFile file, @Nullable String defaultValue, int line, int column) { public static CompilerMessageLocation psiFileToMessageLocation(
@NotNull PsiFile file,
@Nullable String defaultValue,
@NotNull DiagnosticUtils.LineAndColumn lineAndColumn
) {
String path; String path;
VirtualFile virtualFile = file.getVirtualFile(); VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) { if (virtualFile == null) {
@@ -51,6 +54,6 @@ public class MessageUtil {
path = toSystemDependentName(path); path = toSystemDependentName(path);
} }
} }
return CompilerMessageLocation.create(path, line, column); return CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn(), lineAndColumn.getLineContent());
} }
} }
@@ -128,16 +128,19 @@ public class DiagnosticUtils {
} }
@NotNull @NotNull
public static LineAndColumn offsetToLineAndColumn(Document document, int offset) { public static LineAndColumn offsetToLineAndColumn(@Nullable Document document, int offset) {
if (document == null) { if (document == null) {
return new LineAndColumn(-1, offset); return new LineAndColumn(-1, offset, null);
} }
int lineNumber = document.getLineNumber(offset); int lineNumber = document.getLineNumber(offset);
int lineStartOffset = document.getLineStartOffset(lineNumber); int lineStartOffset = document.getLineStartOffset(lineNumber);
int column = offset - lineStartOffset; int column = offset - lineStartOffset;
return new LineAndColumn(lineNumber + 1, column + 1); int lineEndOffset = document.getLineEndOffset(lineNumber);
CharSequence lineContent = document.getCharsSequence().subSequence(lineStartOffset, lineEndOffset);
return new LineAndColumn(lineNumber + 1, column + 1, lineContent.toString());
} }
public static void throwIfRunningOnServer(Throwable e) { public static void throwIfRunningOnServer(Throwable e) {
@@ -184,14 +187,16 @@ public class DiagnosticUtils {
public static final class LineAndColumn { public static final class LineAndColumn {
public static final LineAndColumn NONE = new LineAndColumn(-1, -1); public static final LineAndColumn NONE = new LineAndColumn(-1, -1, null);
private final int line; private final int line;
private final int column; private final int column;
private final String lineContent;
public LineAndColumn(int line, int column) { public LineAndColumn(int line, int column, @Nullable String lineContent) {
this.line = line; this.line = line;
this.column = column; this.column = column;
this.lineContent = lineContent;
} }
public int getLine() { public int getLine() {
@@ -202,6 +207,11 @@ public class DiagnosticUtils {
return column; return column;
} }
@Nullable
public String getLineContent() {
return lineContent;
}
// NOTE: This method is used for presenting positions to the user // NOTE: This method is used for presenting positions to the user
@Override @Override
public String toString() { public String toString() {
+3 -1
View File
@@ -1,2 +1,4 @@
ERROR: compiler/testData/cli/js/diagnosticForClassLiteral.kt: (6, 5) Cannot translate (not supported yet): 'A::class' compiler/testData/cli/js/diagnosticForClassLiteral.kt:6:5: error: cannot translate (not supported yet): 'A::class'
A::class
^
COMPILATION_ERROR COMPILATION_ERROR
@@ -1,2 +1,4 @@
ERROR: compiler/testData/cli/js/diagnosticForUnhandledElements.kt: (9, 17) Cannot translate (not supported yet): '@fancy 1' compiler/testData/cli/js/diagnosticForUnhandledElements.kt:9:17: error: cannot translate (not supported yet): '@fancy 1'
COMPILATION_ERROR return (@fancy 1)
^
COMPILATION_ERROR
@@ -1,3 +1,7 @@
ERROR: compiler/testData/cli/js/diagnosticWhenReferenceToBuiltinsMember.kt: (4, 5) Callable references for builtin members are not supported yet: 'Int::toByte' compiler/testData/cli/js/diagnosticWhenReferenceToBuiltinsMember.kt:4:5: error: callable references for builtin members are not supported yet: 'Int::toByte'
ERROR: compiler/testData/cli/js/diagnosticWhenReferenceToBuiltinsMember.kt: (5, 5) Callable references for builtin members are not supported yet: 'String::length' Int::toByte
^
compiler/testData/cli/js/diagnosticWhenReferenceToBuiltinsMember.kt:5:5: error: callable references for builtin members are not supported yet: 'String::length'
String::length
^
COMPILATION_ERROR COMPILATION_ERROR
+2 -2
View File
@@ -1,2 +1,2 @@
ERROR: No source files error: no source files
COMPILATION_ERROR COMPILATION_ERROR
+7 -3
View File
@@ -1,3 +1,7 @@
ERROR: compiler/testData/cli/js/inlineCycle.kt: (2, 5) The 'b' invocation is a part of inline cycle compiler/testData/cli/js/inlineCycle.kt:2:5: error: the 'b' invocation is a part of inline cycle
ERROR: compiler/testData/cli/js/inlineCycle.kt: (15, 5) The 'a' invocation is a part of inline cycle b(l)
COMPILATION_ERROR ^
compiler/testData/cli/js/inlineCycle.kt:15:5: error: the 'a' invocation is a part of inline cycle
a(p)
^
COMPILATION_ERROR
+1 -1
View File
@@ -1,2 +1,2 @@
ERROR: Path 'not/existing/path' does not exist error: path 'not/existing/path' does not exist
COMPILATION_ERROR COMPILATION_ERROR
+2 -2
View File
@@ -1,2 +1,2 @@
ERROR: Source file or directory not found: not/existing/path error: source file or directory not found: not/existing/path
COMPILATION_ERROR COMPILATION_ERROR
+2 -2
View File
@@ -1,2 +1,2 @@
ERROR: 'compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib' is not a valid Kotlin Javascript library error: 'compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib' is not a valid Kotlin Javascript library
COMPILATION_ERROR COMPILATION_ERROR
+2 -2
View File
@@ -1,2 +1,2 @@
ERROR: Cannot open output file 'compiler/testData/cli/js': is a directory error: cannot open output file 'compiler/testData/cli/js': is a directory
COMPILATION_ERROR COMPILATION_ERROR
+1 -1
View File
@@ -1,2 +1,2 @@
ERROR: Output postfix file 'not/existing/path' not found error: output postfix file 'not/existing/path' not found
COMPILATION_ERROR COMPILATION_ERROR
+1 -1
View File
@@ -1,2 +1,2 @@
ERROR: Output prefix file 'not/existing/path' not found error: output prefix file 'not/existing/path' not found
COMPILATION_ERROR COMPILATION_ERROR
+2 -2
View File
@@ -1,2 +1,2 @@
ERROR: File 'compiler/testData/cli/js/wrongAbiVersionLib/wrongAbiLib.meta.js' was compiled with an incompatible version of Kotlin. Its ABI version is 0, expected ABI version is 3 error: file 'compiler/testData/cli/js/wrongAbiVersionLib/wrongAbiLib.meta.js' was compiled with an incompatible version of Kotlin. Its ABI version is 0, expected ABI version is 3
COMPILATION_ERROR COMPILATION_ERROR
+16 -6
View File
@@ -1,6 +1,16 @@
WARNING: compiler/testData/cli/jvm/classpath.kt: (8, 9) Variable 'a' is never used compiler/testData/cli/jvm/classpath.kt:8:9: warning: variable 'a' is never used
WARNING: compiler/testData/cli/jvm/classpath.kt: (9, 9) Variable 'c' is never used val a = Big5() // charsets.jar
WARNING: compiler/testData/cli/jvm/classpath.kt: (10, 9) Variable 'e' is never used ^
WARNING: compiler/testData/cli/jvm/classpath.kt: (11, 9) Variable 'f' is never used compiler/testData/cli/jvm/classpath.kt:9:9: warning: variable 'c' is never used
WARNING: compiler/testData/cli/jvm/classpath.kt: (12, 9) Variable 'j' is never used val c = DNSNameService() // dnsns.ajr
OK ^
compiler/testData/cli/jvm/classpath.kt:10:9: warning: variable 'e' is never used
val e : Cipher? = null // jce.jar
^
compiler/testData/cli/jvm/classpath.kt:11:9: warning: variable 'f' is never used
val f : SunJCE? = null // sunjce_provider.jar
^
compiler/testData/cli/jvm/classpath.kt:12:9: warning: variable 'j' is never used
val j : ByteBuffered? = null // rt.jar
^
OK
+7 -3
View File
@@ -1,3 +1,7 @@
ERROR: compiler/testData/cli/jvm/conflictingOverloads.kt: (1, 1) 'internal fun a(): kotlin.List<kotlin.Int>' is already defined in root package compiler/testData/cli/jvm/conflictingOverloads.kt:1:1: error: 'internal fun a(): kotlin.List<kotlin.Int>' is already defined in root package
ERROR: compiler/testData/cli/jvm/conflictingOverloads.kt: (2, 1) 'internal fun a(): kotlin.List<kotlin.String>' is already defined in root package fun a(): List<Int> = null!!
COMPILATION_ERROR ^
compiler/testData/cli/jvm/conflictingOverloads.kt:2:1: error: 'internal fun a(): kotlin.List<kotlin.String>' is already defined in root package
fun a(): List<String> = null!!
^
COMPILATION_ERROR
+27 -9
View File
@@ -1,10 +1,28 @@
ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (1, 5) Redeclaration: x compiler/testData/cli/jvm/diagnosticsOrder1.kt:1:5: error: redeclaration: x
ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (2, 5) Redeclaration: x val x = 5
ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (3, 5) Redeclaration: x ^
ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (4, 5) Redeclaration: x compiler/testData/cli/jvm/diagnosticsOrder1.kt:2:5: error: redeclaration: x
ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (5, 5) Redeclaration: x val x = 5
ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (6, 5) Redeclaration: x ^
ERROR: compiler/testData/cli/jvm/diagnosticsOrder1.kt: (7, 5) Redeclaration: x compiler/testData/cli/jvm/diagnosticsOrder1.kt:3:5: error: redeclaration: x
ERROR: compiler/testData/cli/jvm/diagnosticsOrder2.kt: (1, 5) Redeclaration: y val x = 5
ERROR: compiler/testData/cli/jvm/diagnosticsOrder2.kt: (2, 5) Redeclaration: y ^
compiler/testData/cli/jvm/diagnosticsOrder1.kt:4:5: error: redeclaration: x
val x = 5
^
compiler/testData/cli/jvm/diagnosticsOrder1.kt:5:5: error: redeclaration: x
val x = 5
^
compiler/testData/cli/jvm/diagnosticsOrder1.kt:6:5: error: redeclaration: x
val x = 5
^
compiler/testData/cli/jvm/diagnosticsOrder1.kt:7:5: error: redeclaration: x
val x = 5
^
compiler/testData/cli/jvm/diagnosticsOrder2.kt:1:5: error: redeclaration: y
val y = 5
^
compiler/testData/cli/jvm/diagnosticsOrder2.kt:2:5: error: redeclaration: y
val y = 5
^
COMPILATION_ERROR COMPILATION_ERROR
+2 -2
View File
@@ -1,2 +1,2 @@
WARNING: Duplicate source root: compiler/testData/cli/jvm/simple.kt warning: duplicate source root: compiler/testData/cli/jvm/simple.kt
OK OK
+2 -2
View File
@@ -1,2 +1,2 @@
WARNING: Duplicate source root: $TESTDATA_DIR$/duplicateSourcesInModule.kt warning: duplicate source root: $TESTDATA_DIR$/duplicateSourcesInModule.kt
OK OK
+2 -2
View File
@@ -1,2 +1,2 @@
ERROR: No source files error: no source files
COMPILATION_ERROR COMPILATION_ERROR
+7 -3
View File
@@ -1,3 +1,7 @@
ERROR: compiler/testData/cli/jvm/inlineCycle.kt: (2, 5) The 'b' invocation is a part of inline cycle compiler/testData/cli/jvm/inlineCycle.kt:2:5: error: the 'b' invocation is a part of inline cycle
ERROR: compiler/testData/cli/jvm/inlineCycle.kt: (15, 5) The 'a' invocation is a part of inline cycle b(l)
COMPILATION_ERROR ^
compiler/testData/cli/jvm/inlineCycle.kt:15:5: error: the 'a' invocation is a part of inline cycle
a(p)
^
COMPILATION_ERROR
@@ -1,4 +1,10 @@
ERROR: compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt: (6, 14) Cannot weaken access privilege 'public' for 'c' in 'A' compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:14: error: cannot weaken access privilege 'public' for 'c' in 'A'
ERROR: compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt: (6, 14) Incompatible modifiers: 'private protected' override protected private val c: Int
ERROR: compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt: (6, 24) Incompatible modifiers: 'private protected' ^
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:14: error: incompatible modifiers: 'private protected'
override protected private val c: Int
^
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:24: error: incompatible modifiers: 'private protected'
override protected private val c: Int
^
COMPILATION_ERROR COMPILATION_ERROR
+6 -2
View File
@@ -1,3 +1,7 @@
ERROR: compiler/testData/cli/jvm/noReflectionInClasspath.kt: (3, 12) Expression 'Foo::prop' uses reflection which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath compiler/testData/cli/jvm/noReflectionInClasspath.kt:3:12: error: expression 'Foo::prop' uses reflection which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath
ERROR: compiler/testData/cli/jvm/noReflectionInClasspath.kt: (4, 12) Expression 'Foo::class' uses reflection which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath fun t1() = Foo::prop
^
compiler/testData/cli/jvm/noReflectionInClasspath.kt:4:12: error: expression 'Foo::class' uses reflection which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath
fun t2() = Foo::class
^
COMPILATION_ERROR COMPILATION_ERROR
@@ -1,3 +1,3 @@
WARNING: Classpath entry points to a non-existent location: not/existing/path warning: classpath entry points to a non-existent location: not/existing/path
WARNING: Annotations path entry points to a non-existent location: yet/another/not/existing/path warning: annotations path entry points to a non-existent location: yet/another/not/existing/path
OK OK
+1 -1
View File
@@ -1,2 +1,2 @@
ERROR: Source file or directory not found: not/existing/path error: source file or directory not found: not/existing/path
COMPILATION_ERROR COMPILATION_ERROR
+7 -3
View File
@@ -1,3 +1,7 @@
ERROR: compiler/testData/cli/jvm/nonLocalDisabled.kt: (3, 9) Non-local returns are not allowed with inlining disabled compiler/testData/cli/jvm/nonLocalDisabled.kt:3:9: error: non-local returns are not allowed with inlining disabled
ERROR: compiler/testData/cli/jvm/nonLocalDisabled.kt: (7, 9) Non-local returns are not allowed with inlining disabled return
COMPILATION_ERROR ^
compiler/testData/cli/jvm/nonLocalDisabled.kt:7:9: error: non-local returns are not allowed with inlining disabled
return@a
^
COMPILATION_ERROR
+2 -2
View File
@@ -1,8 +1,8 @@
ERROR: Required plugin option not present: org.jetbrains.kotlin.android:androidRes error: required plugin option not present: org.jetbrains.kotlin.android:androidRes
Plugin "org.jetbrains.kotlin.android" usage: Plugin "org.jetbrains.kotlin.android" usage:
androidRes <path> Android resources path (required, multiple) androidRes <path> Android resources path (required, multiple)
androidManifest <path> Android manifest file (required) androidManifest <path> Android manifest file (required)
supportV4 <path> Support android-v4 library supportV4 <path> Support android-v4 library
COMPILATION_ERROR COMPILATION_ERROR
+28 -10
View File
@@ -1,28 +1,46 @@
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (6, 5) Accidental override: The following declarations have the same JVM signature (getX()I): compiler/testData/cli/jvm/signatureClash.kt:6:5: error: accidental override: The following declarations have the same JVM signature (getX()I):
fun getX(): kotlin.Int fun getX(): kotlin.Int
fun <get-x>(): kotlin.Int fun <get-x>(): kotlin.Int
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (8, 5) Platform declaration clash: The following declarations have the same JVM signature (getA()I): fun getX() = 1
^
compiler/testData/cli/jvm/signatureClash.kt:8:5: error: platform declaration clash: The following declarations have the same JVM signature (getA()I):
fun getA(): kotlin.Int fun getA(): kotlin.Int
fun <get-a>(): kotlin.Int fun <get-a>(): kotlin.Int
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (9, 5) Platform declaration clash: The following declarations have the same JVM signature (getA()I): fun getA(): Int = 1
^
compiler/testData/cli/jvm/signatureClash.kt:9:5: error: platform declaration clash: The following declarations have the same JVM signature (getA()I):
fun getA(): kotlin.Int fun getA(): kotlin.Int
fun <get-a>(): kotlin.Int fun <get-a>(): kotlin.Int
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (12, 1) Platform declaration clash: The following declarations have the same JVM signature (getB()I): val a: Int = 1
^
compiler/testData/cli/jvm/signatureClash.kt:12:1: error: platform declaration clash: The following declarations have the same JVM signature (getB()I):
fun <get-b>(): kotlin.Int fun <get-b>(): kotlin.Int
fun getB(): kotlin.Int fun getB(): kotlin.Int
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (13, 1) Platform declaration clash: The following declarations have the same JVM signature (getB()I): fun getB(): Int = 1
^
compiler/testData/cli/jvm/signatureClash.kt:13:1: error: platform declaration clash: The following declarations have the same JVM signature (getB()I):
fun <get-b>(): kotlin.Int fun <get-b>(): kotlin.Int
fun getB(): kotlin.Int fun getB(): kotlin.Int
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (19, 7) Platform declaration clash: The following declarations have the same JVM signature (getTr()I): val b: Int = 1
^
compiler/testData/cli/jvm/signatureClash.kt:19:7: error: platform declaration clash: The following declarations have the same JVM signature (getTr()I):
fun <get-tr>(): kotlin.Int fun <get-tr>(): kotlin.Int
fun getTr(): kotlin.Int fun getTr(): kotlin.Int
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (20, 5) Platform declaration clash: The following declarations have the same JVM signature (getTr()I): class SubTr : Tr {
^
compiler/testData/cli/jvm/signatureClash.kt:20:5: error: platform declaration clash: The following declarations have the same JVM signature (getTr()I):
fun <get-tr>(): kotlin.Int fun <get-tr>(): kotlin.Int
fun getTr(): kotlin.Int fun getTr(): kotlin.Int
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (24, 7) Platform declaration clash: The following declarations have the same JVM signature (access$f$0(LC;)V): val tr = 1
^
compiler/testData/cli/jvm/signatureClash.kt:24:7: error: platform declaration clash: The following declarations have the same JVM signature (access$f$0(LC;)V):
fun `access$f$0`(c: C): kotlin.Unit fun `access$f$0`(c: C): kotlin.Unit
fun f(): kotlin.Unit fun f(): kotlin.Unit
ERROR: compiler/testData/cli/jvm/signatureClash.kt: (26, 5) Platform declaration clash: The following declarations have the same JVM signature (access$f$0(LC;)V): class C {
^
compiler/testData/cli/jvm/signatureClash.kt:26:5: error: platform declaration clash: The following declarations have the same JVM signature (access$f$0(LC;)V):
fun `access$f$0`(c: C): kotlin.Unit fun `access$f$0`(c: C): kotlin.Unit
fun f(): kotlin.Unit fun f(): kotlin.Unit
COMPILATION_ERROR fun `access$f$0`(c: C) {}
^
COMPILATION_ERROR
@@ -1,19 +1,31 @@
ERROR: compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt: (15, 5) Accidental override: The following declarations have the same JVM signature (access$foo$0(LDerived;)V): compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:15:5: error: accidental override: The following declarations have the same JVM signature (access$foo$0(LDerived;)V):
fun `access$foo$0`(d: Derived): kotlin.Unit fun `access$foo$0`(d: Derived): kotlin.Unit
fun foo(): kotlin.Unit fun foo(): kotlin.Unit
ERROR: compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt: (18, 9) Accidental override: The following declarations have the same JVM signature (access$getBar$1(LDerived;)I): private fun foo() {}
^
compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:18:9: error: accidental override: The following declarations have the same JVM signature (access$getBar$1(LDerived;)I):
fun `access$getBar$1`(d: Derived): kotlin.Int fun `access$getBar$1`(d: Derived): kotlin.Int
fun <get-bar>(): kotlin.Int fun <get-bar>(): kotlin.Int
ERROR: compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt: (19, 9) Accidental override: The following declarations have the same JVM signature (access$setBar$1(LDerived;I)V): get
^
compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:19:9: error: accidental override: The following declarations have the same JVM signature (access$setBar$1(LDerived;I)V):
fun `access$setBar$1`(d: Derived, i: kotlin.Int): kotlin.Unit fun `access$setBar$1`(d: Derived, i: kotlin.Int): kotlin.Unit
fun <set-bar>(<set-?>: kotlin.Int): kotlin.Unit fun <set-bar>(<set-?>: kotlin.Int): kotlin.Unit
ERROR: compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt: (21, 5) Accidental override: The following declarations have the same JVM signature (access$getBaz$2(LDerived;)I): set
^
compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:21:5: error: accidental override: The following declarations have the same JVM signature (access$getBaz$2(LDerived;)I):
fun `access$getBaz$2`(d: Derived): kotlin.Int fun `access$getBaz$2`(d: Derived): kotlin.Int
fun <get-baz>(): kotlin.Int fun <get-baz>(): kotlin.Int
ERROR: compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt: (23, 5) Accidental override: The following declarations have the same JVM signature (access$getBoo$3(LDerived;)I): private var baz = 1
^
compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:23:5: error: accidental override: The following declarations have the same JVM signature (access$getBoo$3(LDerived;)I):
fun `access$getBoo$3`(d: Derived): kotlin.Int fun `access$getBoo$3`(d: Derived): kotlin.Int
fun <get-boo>(): kotlin.Int fun <get-boo>(): kotlin.Int
ERROR: compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt: (27, 9) Accidental override: The following declarations have the same JVM signature (access$setBar1$4(LDerived;I)V): private val boo = 1
^
compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:27:9: error: accidental override: The following declarations have the same JVM signature (access$setBar1$4(LDerived;I)V):
fun `access$setBar1$4`(d: Derived, i: kotlin.Int): kotlin.Unit fun `access$setBar1$4`(d: Derived, i: kotlin.Int): kotlin.Unit
fun <set-bar1>(<set-?>: kotlin.Int): kotlin.Unit fun <set-bar1>(<set-?>: kotlin.Int): kotlin.Unit
COMPILATION_ERROR set
^
COMPILATION_ERROR
+6 -4
View File
@@ -1,4 +1,6 @@
ERROR: compiler/testData/cli/jvm/wrongAbiVersionLib/bin/ClassWithWrongAbiVersion.class: Class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$ compiler/testData/cli/jvm/wrongAbiVersionLib/bin/ClassWithWrongAbiVersion.class: error: class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$
ERROR: compiler/testData/cli/jvm/wrongAbiVersionLib/bin/wrong/WrongPackage.class: Class 'wrong/WrongPackage' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$ compiler/testData/cli/jvm/wrongAbiVersionLib/bin/wrong/WrongPackage.class: error: class 'wrong/WrongPackage' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is $ABI_VERSION$
ERROR: compiler/testData/cli/jvm/wrongAbiVersion.kt: (4, 3) Unresolved reference: bar compiler/testData/cli/jvm/wrongAbiVersion.kt:4:3: error: unresolved reference: bar
COMPILATION_ERROR bar()
^
COMPILATION_ERROR
+1 -1
View File
@@ -1,4 +1,4 @@
ERROR: The following Java entities have annotations with wrong Kotlin signatures: error: the following Java entities have annotations with wrong Kotlin signatures:
library.ClassWithWrongKotlinSignatures java.lang.String foo(): library.ClassWithWrongKotlinSignatures java.lang.String foo():
Function names mismatch, original: foo, alternative: bar Function names mismatch, original: foo, alternative: bar
library.ClassWithWrongKotlinSignatures java.lang.String bar(): library.ClassWithWrongKotlinSignatures java.lang.String bar():
+2 -2
View File
@@ -1,2 +1,2 @@
ERROR: Specify script source path to evaluate error: specify script source path to evaluate
COMPILATION_ERROR COMPILATION_ERROR
@@ -1,5 +1,7 @@
ERROR: compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt: (5, 22) Unresolved reference: foo compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt:5:22: error: unresolved reference: foo
ERROR: The following classes have incomplete hierarchies: fun bar() = SubSub().foo()
^
error: the following classes have incomplete hierarchies:
test.Sub, unresolved: [Super] test.Sub, unresolved: [Super]
COMPILATION_ERROR COMPILATION_ERROR
@@ -3,8 +3,8 @@ Buildfile: [TestData]/build.xml
build: build:
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
[kotlin2js] LOGGING: Compiling source files: [TestData]/root1/foo.kt [kotlin2js] logging: compiling source files: [TestData]/root1/foo.kt
[kotlin2js] OUTPUT: Output: [kotlin2js] output: output:
[kotlin2js] [Temp]/out.js [kotlin2js] [Temp]/out.js
[kotlin2js] Sources: [kotlin2js] Sources:
[kotlin2js] [TestData]/root1/foo.kt [kotlin2js] [TestData]/root1/foo.kt
@@ -3,7 +3,7 @@ Buildfile: [TestData]/build.xml
build: build:
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
[kotlin2js] INFO: Kotlin Compiler version [KotlinVersion] [kotlin2js] info: Kotlin Compiler version [KotlinVersion]
BUILD SUCCESSFUL BUILD SUCCESSFUL
Total time: [time] Total time: [time]
@@ -5,7 +5,7 @@ build:
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar] [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
[javac] Compiling 1 source file to [Temp] [javac] Compiling 1 source file to [Temp]
[javac] Compiling [[TestData]] => [[Temp]] [javac] Compiling [[TestData]] => [[Temp]]
[javac] INFO: Kotlin Compiler version [KotlinVersion] [javac] info: Kotlin Compiler version [KotlinVersion]
[javac] Running javac... [javac] Running javac...
BUILD SUCCESSFUL BUILD SUCCESSFUL
@@ -4,13 +4,25 @@ Buildfile: [TestData]/build.xml
build: build:
[javac] Compiling 2 source files to [Temp] [javac] Compiling 2 source files to [Temp]
[javac] Compiling [[TestData]] => [[Temp]] [javac] Compiling [[TestData]] => [[Temp]]
[javac] ERROR: [TestData]/incorrectKotlinCode.kt: (4, 1) Parameter name expected [javac] [TestData]/incorrectKotlinCode.kt:4:1: error: parameter name expected
[javac] ERROR: [TestData]/incorrectKotlinCode.kt: (4, 1) Expecting comma or ')' [javac]
[javac] ERROR: [TestData]/incorrectKotlinCode.kt: (4, 1) Expecting ')' [javac] ^
[javac] [TestData]/incorrectKotlinCode.kt:4:1: error: expecting comma or ')'
[javac]
[javac] ^
[javac] [TestData]/incorrectKotlinCode.kt:4:1: error: expecting ')'
[javac]
[javac] ^
[kotlinc] Compiling [[TestData]] => [[Temp]] [kotlinc] Compiling [[TestData]] => [[Temp]]
[kotlinc] ERROR: [TestData]/incorrectKotlinCode.kt: (4, 1) Parameter name expected [kotlinc] [TestData]/incorrectKotlinCode.kt:4:1: error: parameter name expected
[kotlinc] ERROR: [TestData]/incorrectKotlinCode.kt: (4, 1) Expecting comma or ')' [kotlinc]
[kotlinc] ERROR: [TestData]/incorrectKotlinCode.kt: (4, 1) Expecting ')' [kotlinc] ^
[kotlinc] [TestData]/incorrectKotlinCode.kt:4:1: error: expecting comma or ')'
[kotlinc]
[kotlinc] ^
[kotlinc] [TestData]/incorrectKotlinCode.kt:4:1: error: expecting ')'
[kotlinc]
[kotlinc] ^
BUILD SUCCESSFUL BUILD SUCCESSFUL
Total time: [time] Total time: [time]
@@ -3,7 +3,9 @@ Buildfile: [TestData]/build.xml
build: build:
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar] [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
[kotlinc] WARNING: [TestData]/hello.kt: (15, 9) Variable 'result' is never used [kotlinc] [TestData]/hello.kt:15:9: warning: variable 'result' is never used
[kotlinc] val result = "$a$c$e$f$j"
[kotlinc] ^
[java] OK [java] OK
BUILD SUCCESSFUL BUILD SUCCESSFUL
@@ -3,8 +3,8 @@ Buildfile: [TestData]/build.xml
build: build:
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar] [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
[kotlinc] LOGGING: Using Kotlin home directory [KotlinProjectHome]/dist/kotlinc [kotlinc] logging: using Kotlin home directory [KotlinProjectHome]/dist/kotlinc
[kotlinc] LOGGING: Configuring the compilation environment [kotlinc] logging: configuring the compilation environment
BUILD SUCCESSFUL BUILD SUCCESSFUL
Total time: [time] Total time: [time]
@@ -3,7 +3,7 @@ Buildfile: [TestData]/build.xml
build: build:
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar] [kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
[kotlinc] INFO: Kotlin Compiler version [KotlinVersion] [kotlinc] info: Kotlin Compiler version [KotlinVersion]
BUILD SUCCESSFUL BUILD SUCCESSFUL
Total time: [time] Total time: [time]
@@ -1,5 +1,7 @@
ERR: ERR:
ERROR: hello.kt: (4, 5) Unresolved reference: a hello.kt:4:5: error: unresolved reference: a
a
^
Return code: 1 Return code: 1
@@ -1,5 +1,7 @@
ERR: ERR:
ERROR: test.kt: (4, 20) Expecting an element test.kt:4:20: error: expecting an element
val s = System.in
^
Return code: 1 Return code: 1
+3 -1
View File
@@ -1,5 +1,7 @@
>>> fun foo() = 765 >>> fun foo() = 765
>>> foo(1) >>> foo(1)
ERROR: /line2.kts: (1, 5) Too many arguments for internal final fun foo(): kotlin.Int defined in <script> /line2.kts:1:5: error: too many arguments for internal final fun foo(): kotlin.Int defined in <script>
foo(1)
^
>>> foo() >>> foo()
765 765
+3 -1
View File
@@ -2,4 +2,6 @@
... object Bar { ... object Bar {
... } ... }
... } ... }
ERROR: /line4.kts: (2, 1) Named object 'Bar' is a singleton and cannot be local. Try to use anonymous object instead /line4.kts:2:1: error: named object 'Bar' is a singleton and cannot be local. Try to use anonymous object instead
object Bar {
^
+6 -2
View File
@@ -1,6 +1,10 @@
>>> )( >>> )(
ERROR: /line1.kts: (1, 1) Expecting an element /line1.kts:1:1: error: expecting an element
ERROR: /line1.kts: (1, 3) Expecting an expression )(
^
/line1.kts:1:3: error: expecting an expression
)(
^
>>> fun foo() = 98 >>> fun foo() = 98
>>> foo() >>> foo()
98 98
@@ -161,7 +161,7 @@ public class CompilerOutputParser {
reportToCollector(text); reportToCollector(text);
} }
else { else {
messageCollector.report(category, text, CompilerMessageLocation.create(path, line, column)); messageCollector.report(category, text, CompilerMessageLocation.create(path, line, column, null));
} }
tags.pop(); tags.pop();
} }