diff options
author | odersky <odersky@gmail.com> | 2017-02-21 14:03:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 14:03:10 +0100 |
commit | 9f879c1677b467037f6c19cc0abe43e0adb802fa (patch) | |
tree | c4d473764ac0fd79e0f4d00e4a361fdc595cd90c /tests | |
parent | f467be62da8978e506f58b702b84e74ef7ce09de (diff) | |
parent | bd80a187c3792a4891bec72e0b27b858a5a992ab (diff) | |
download | dotty-9f879c1677b467037f6c19cc0abe43e0adb802fa.tar.gz dotty-9f879c1677b467037f6c19cc0abe43e0adb802fa.tar.bz2 dotty-9f879c1677b467037f6c19cc0abe43e0adb802fa.zip |
Merge pull request #1996 from dotty-staging/fix-#1990
Fix #1990: Handle inlining where this proxies change types
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/i1990.scala | 12 | ||||
-rw-r--r-- | tests/pos/i1990a.scala | 20 | ||||
-rw-r--r-- | tests/run/builder.check | 1 | ||||
-rw-r--r-- | tests/run/builder.scala | 51 | ||||
-rw-r--r-- | tests/run/i1990b.check | 1 | ||||
-rw-r--r-- | tests/run/i1990b.scala | 20 |
6 files changed, 105 insertions, 0 deletions
diff --git a/tests/pos/i1990.scala b/tests/pos/i1990.scala new file mode 100644 index 000000000..77cea0af7 --- /dev/null +++ b/tests/pos/i1990.scala @@ -0,0 +1,12 @@ +class A { + class Foo { + inline def inlineMeth: Unit = { + new Bar + } + } + class Bar +} + +class B extends A { + (new Foo).inlineMeth +} diff --git a/tests/pos/i1990a.scala b/tests/pos/i1990a.scala new file mode 100644 index 000000000..f6f95ee36 --- /dev/null +++ b/tests/pos/i1990a.scala @@ -0,0 +1,20 @@ +class A { self => + class Foo { + inline def inlineMeth: Unit = { + println(self) + } + } +} + +class C extends A { + class B extends A +} + +object Test { + def main(args: Array[String]): Unit = { + val c = new C + val b = new c.B + + (new b.Foo).inlineMeth + } +} diff --git a/tests/run/builder.check b/tests/run/builder.check new file mode 100644 index 000000000..48f7d9253 --- /dev/null +++ b/tests/run/builder.check @@ -0,0 +1 @@ +Table(Row(Cell(A1), Cell(B1)), Row(Cell(A2), Cell(B2))) diff --git a/tests/run/builder.scala b/tests/run/builder.scala new file mode 100644 index 000000000..532a95071 --- /dev/null +++ b/tests/run/builder.scala @@ -0,0 +1,51 @@ +import collection.mutable.ArrayBuffer + +class Table { + val rows = new ArrayBuffer[Row] + def add(r: Row): Unit = rows += r + override def toString = rows.mkString("Table(", ", ", ")") +} + +class Row { + val cells = new ArrayBuffer[Cell] + def add(c: Cell): Unit = cells += c + override def toString = cells.mkString("Row(", ", ", ")") +} + +class Cell(elem: String) { + override def toString = s"Cell($elem)" +} + +object Test { + + def table(init: implicit Table => Unit) = { + implicit val t = new Table + init + t + } + + def row(init: implicit Row => Unit)(implicit t: Table) = { + implicit val r = new Row + init + t.add(r) + } + + def cell(str: String)(implicit r: Row) = + r.add(new Cell(str)) + + val data = + table { + row { + cell("A1") + cell("B1") + } + row { + cell("A2") + cell("B2") + } + } + + def main(args: Array[String]) = { + println(data) + } +} diff --git a/tests/run/i1990b.check b/tests/run/i1990b.check new file mode 100644 index 000000000..dd84bc9fb --- /dev/null +++ b/tests/run/i1990b.check @@ -0,0 +1 @@ +C() diff --git a/tests/run/i1990b.scala b/tests/run/i1990b.scala new file mode 100644 index 000000000..2460208db --- /dev/null +++ b/tests/run/i1990b.scala @@ -0,0 +1,20 @@ +trait A { self => + class Foo { + inline def inlineMeth: Unit = { + println(self) + } + } +} + +case class A2() extends A { + case class C() extends Foo with A + + val c = new C + (new c.Foo).inlineMeth +} + +object Test { + def main(args: Array[String]): Unit = { + new A2 + } +} |