aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/test/dotty/tools/dotc/reporting')
-rw-r--r--compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala39
1 files changed, 37 insertions, 2 deletions
diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala
index 257d40bb0..0c40ec477 100644
--- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala
+++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala
@@ -6,7 +6,7 @@ import core.Contexts.Context
import diagnostic.messages._
import dotty.tools.dotc.parsing.Tokens
import org.junit.Assert._
-import org.junit.Test
+import org.junit.{Ignore, Test}
class ErrorMessagesTests extends ErrorMessagesTest {
// In the case where there are no errors, we can do "expectNoErrors" in the
@@ -227,10 +227,27 @@ class ErrorMessagesTests extends ErrorMessagesTest {
val defn = ictx.definitions
assertMessageCount(1, messages)
- val OverloadedOrRecursiveMethodNeedsResultType(tree) :: Nil = messages
+ val OverloadedMethodNeedsResultType(tree) :: Nil = messages
assertEquals("foo", tree.show)
}
+ @Test @Ignore def recursiveMethodNeedsReturnType =
+ checkMessagesAfter("frontend") {
+ """
+ |class Scope() {
+ | def i = i + 5
+ |}
+ """.stripMargin
+ }
+ .expect { (ictx, messages) =>
+ implicit val ctx: Context = ictx
+ val defn = ictx.definitions
+
+ assertMessageCount(1, messages)
+ val RecursiveMethodNeedsResultType(tree) :: Nil = messages
+ assertEquals("i", tree.show)
+ }
+
@Test def recursiveValueNeedsReturnType =
checkMessagesAfter("frontend") {
"""
@@ -248,6 +265,24 @@ class ErrorMessagesTests extends ErrorMessagesTest {
assertEquals("i", tree.show)
}
+ @Test def cyclicReferenceInvolving =
+ checkMessagesAfter("frontend") {
+ """
+ |class A {
+ | val x: T = ???
+ | type T <: x.type // error: cyclic reference involving value x
+ |}
+ """.stripMargin
+ }
+ .expect { (ictx, messages) =>
+ implicit val ctx: Context = ictx
+ val defn = ictx.definitions
+
+ assertMessageCount(1, messages)
+ val CyclicReferenceInvolving(denot) :: Nil = messages
+ assertEquals("value x", denot.show)
+ }
+
@Test def cyclicReferenceInvolvingImplicit =
checkMessagesAfter("frontend") {
"""