diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-02-15 15:37:55 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-03-31 14:49:23 +0200 |
commit | 07833e93f62cbe6d866300475288e8a763a36198 (patch) | |
tree | ca68403be647950d5a69eda1ba7fef5938f66656 /tests | |
parent | 80b12473d7e7c5551ed7b13a835f239445662813 (diff) | |
download | dotty-07833e93f62cbe6d866300475288e8a763a36198.tar.gz dotty-07833e93f62cbe6d866300475288e8a763a36198.tar.bz2 dotty-07833e93f62cbe6d866300475288e8a763a36198.zip |
FullParametrization: allow to have $this of ThisType.
TailRec methods remain members of enclosing class,
it means that they can refer to methods that require this.type.
It means that tailrec, unlike value classes is not allowed to widen
type of $this to it's full self type.
Fixes #1089
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/tailcall/i1089.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/pos/tailcall/i1089.scala b/tests/pos/tailcall/i1089.scala new file mode 100644 index 000000000..8eb69cb9b --- /dev/null +++ b/tests/pos/tailcall/i1089.scala @@ -0,0 +1,26 @@ +package hello + +import scala.annotation.tailrec + +class Enclosing { + class SomeData(val x: Int) + + def localDef(): Unit = { + def foo(data: SomeData): Int = data.x + + @tailrec + def test(i: Int, data: SomeData): Unit = { + if (i != 0) { + println(foo(data)) + test(i - 1, data) + } + } + + test(3, new SomeData(42)) + } +} + +object world extends App { + println("hello dotty!") + new Enclosing().localDef() +} |