diff options
author | Enno Runne <enno@runne.net> | 2017-03-05 22:26:59 +0100 |
---|---|---|
committer | Enno Runne <enno@runne.net> | 2017-03-05 22:26:59 +0100 |
commit | c3ec6dfbdeadb2fc9e7ac191b4c1a4d6838e8a5b (patch) | |
tree | c1f544d278ed0da4be19fba83d2da3f3b66be7cd /compiler/test/dotty | |
parent | 34e3508cccbbcc49554a4c5b13419769cc3c7bf9 (diff) | |
download | dotty-c3ec6dfbdeadb2fc9e7ac191b4c1a4d6838e8a5b.tar.gz dotty-c3ec6dfbdeadb2fc9e7ac191b4c1a4d6838e8a5b.tar.bz2 dotty-c3ec6dfbdeadb2fc9e7ac191b4c1a4d6838e8a5b.zip |
More detail in error messages
Split error messages for recursive method and overloaded method needs type into two (but
did not solve the analysis which to show).
Make CyclicReference type error construct corresponding error message.
Diffstat (limited to 'compiler/test/dotty')
-rw-r--r-- | compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala | 39 |
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") { """ |