REPL: do not report warnings when there are errors
#KT-18349 Fixed
This commit is contained in:
+15
-5
@@ -16,15 +16,25 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.repl.messages
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.messages.*
|
||||
import org.jetbrains.kotlin.cli.common.messages.GroupingMessageCollector
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorBasedReporter
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.PrintStream
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class ReplTerminalDiagnosticMessageHolder() : MessageCollectorBasedReporter, DiagnosticMessageHolder {
|
||||
class ReplTerminalDiagnosticMessageHolder : MessageCollectorBasedReporter, DiagnosticMessageHolder {
|
||||
private val outputStream = ByteArrayOutputStream()
|
||||
override val messageCollector = PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.WITHOUT_PATHS, false)
|
||||
|
||||
override val messageCollector: GroupingMessageCollector = GroupingMessageCollector(
|
||||
PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.WITHOUT_PATHS, false)
|
||||
)
|
||||
|
||||
override val renderedDiagnostics: String
|
||||
get() = Charsets.UTF_8.decode(ByteBuffer.wrap(outputStream.toByteArray())).toString()
|
||||
}
|
||||
get() {
|
||||
messageCollector.flush()
|
||||
val bytes = outputStream.toByteArray()
|
||||
return Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
error: 'when' expression must be exhaustive, add necessary 'else' branch
|
||||
val a = when(null) { }
|
||||
^
|
||||
warning: the expression is unused
|
||||
val a = when(null) { }
|
||||
^
|
||||
>>> "" + when (true) { true -> 42 }
|
||||
error: 'when' expression must be exhaustive, add necessary 'false' branch or 'else' branch instead
|
||||
"" + when (true) { true -> 42 }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
>>> (listOf(1) as List<String>).unresolved()
|
||||
error: unresolved reference: unresolved
|
||||
(listOf(1) as List<String>).unresolved()
|
||||
^
|
||||
>>> listOf<String>(1!!)
|
||||
error: the integer literal does not conform to the expected type String?
|
||||
listOf<String>(1!!)
|
||||
^
|
||||
error: type mismatch: inferred type is Int but String was expected
|
||||
listOf<String>(1!!)
|
||||
^
|
||||
@@ -114,6 +114,12 @@ public class ReplInterpreterTestGenerated extends AbstractReplInterpreterTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noWarningsWithErrors.repl")
|
||||
public void testNoWarningsWithErrors() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/repl/noWarningsWithErrors.repl");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.repl")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/repl/simple.repl");
|
||||
|
||||
Reference in New Issue
Block a user