diff options
author | Enno Runne <enno@runne.net> | 2017-03-04 16:32:33 +0100 |
---|---|---|
committer | Enno Runne <enno@runne.net> | 2017-03-04 16:32:33 +0100 |
commit | 34e3508cccbbcc49554a4c5b13419769cc3c7bf9 (patch) | |
tree | ea3b36dfe22dbcafd476be88e3512023e5a8d8da /compiler/test/dotty/tools/dotc/reporting | |
parent | e1e13e92d276d76aa73aacc764f64166adbe306c (diff) | |
download | dotty-34e3508cccbbcc49554a4c5b13419769cc3c7bf9.tar.gz dotty-34e3508cccbbcc49554a4c5b13419769cc3c7bf9.tar.bz2 dotty-34e3508cccbbcc49554a4c5b13419769cc3c7bf9.zip |
Explanations for recursive/cyclic type requirements
Diffstat (limited to 'compiler/test/dotty/tools/dotc/reporting')
-rw-r--r-- | compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala index d6e687a1e..257d40bb0 100644 --- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala +++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala @@ -212,4 +212,62 @@ class ErrorMessagesTests extends ErrorMessagesTest { val AnnotatedPrimaryConstructorRequiresModifierOrThis(cls) :: Nil = messages assertEquals("AnotherClass", cls.show) } + + @Test def overloadedMethodNeedsReturnType = + checkMessagesAfter("frontend") { + """ + |class Scope() { + | def foo(i: Int) = foo(i.toString) + | def foo(s: String) = s + |} + """.stripMargin + } + .expect { (ictx, messages) => + implicit val ctx: Context = ictx + val defn = ictx.definitions + + assertMessageCount(1, messages) + val OverloadedOrRecursiveMethodNeedsResultType(tree) :: Nil = messages + assertEquals("foo", tree.show) + } + + @Test def recursiveValueNeedsReturnType = + checkMessagesAfter("frontend") { + """ + |class Scope() { + | lazy val i = i + 5 + |} + """.stripMargin + } + .expect { (ictx, messages) => + implicit val ctx: Context = ictx + val defn = ictx.definitions + + assertMessageCount(1, messages) + val RecursiveValueNeedsResultType(tree) :: Nil = messages + assertEquals("i", tree.show) + } + + @Test def cyclicReferenceInvolvingImplicit = + checkMessagesAfter("frontend") { + """ + |object implicitDefs { + | def foo(implicit x: String) = 1 + | def bar() = { + | implicit val x = foo + | x + | } + |} + """.stripMargin + } + .expect { (ictx, messages) => + implicit val ctx: Context = ictx + val defn = ictx.definitions + + assertMessageCount(1, messages) + val CyclicReferenceInvolvingImplicit(tree) :: Nil = messages + assertEquals("x", tree.name.show) + } + + } |