diff options
author | Stefan Zeiger <szeiger@novocode.com> | 2016-08-12 16:24:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-12 16:24:44 +0200 |
commit | 0d9587a563ff26852732e9bb751f601972fecddc (patch) | |
tree | 45a58df0c2c749417e0af6e5a7ba798ffe8f8ed4 /test | |
parent | 14c02acf4c398bcfe293754ea4757b461f4aa653 (diff) | |
parent | 30876fe2dd8cbe657a6cad6b11bbc34f10c29b36 (diff) | |
download | scala-0d9587a563ff26852732e9bb751f601972fecddc.tar.gz scala-0d9587a563ff26852732e9bb751f601972fecddc.tar.bz2 scala-0d9587a563ff26852732e9bb751f601972fecddc.zip |
Merge pull request #5258 from szeiger/issue/9019
SI-9019 TraversableLike stringPrefix broken for inner classes
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/xMigration.check | 14 | ||||
-rw-r--r-- | test/junit/scala/collection/TraversableLikeTest.scala | 33 |
2 files changed, 40 insertions, 7 deletions
diff --git a/test/files/run/xMigration.check b/test/files/run/xMigration.check index 1104dbea83..b812d6a282 100644 --- a/test/files/run/xMigration.check +++ b/test/files/run/xMigration.check @@ -1,11 +1,11 @@ scala> Map(1 -> "eis").values // no warn -res0: Iterable[String] = MapLike(eis) +res0: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:none scala> Map(1 -> "eis").values // no warn -res1: Iterable[String] = MapLike(eis) +res1: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:any @@ -14,12 +14,12 @@ scala> Map(1 -> "eis").values // warn `values` returns `Iterable[V]` rather than `Iterator[V]`. Map(1 -> "eis").values // warn ^ -res2: Iterable[String] = MapLike(eis) +res2: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.8 scala> Map(1 -> "eis").values // no warn -res3: Iterable[String] = MapLike(eis) +res3: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.7 @@ -28,12 +28,12 @@ scala> Map(1 -> "eis").values // warn `values` returns `Iterable[V]` rather than `Iterator[V]`. Map(1 -> "eis").values // warn ^ -res4: Iterable[String] = MapLike(eis) +res4: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.11 scala> Map(1 -> "eis").values // no warn -res5: Iterable[String] = MapLike(eis) +res5: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration // same as :any @@ -42,6 +42,6 @@ scala> Map(1 -> "eis").values // warn `values` returns `Iterable[V]` rather than `Iterator[V]`. Map(1 -> "eis").values // warn ^ -res6: Iterable[String] = MapLike(eis) +res6: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :quit diff --git a/test/junit/scala/collection/TraversableLikeTest.scala b/test/junit/scala/collection/TraversableLikeTest.scala new file mode 100644 index 0000000000..8588956016 --- /dev/null +++ b/test/junit/scala/collection/TraversableLikeTest.scala @@ -0,0 +1,33 @@ +package scala.collection + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class TraversableLikeTest { + // For test_SI9019; out here because as of test writing, putting this in a method would crash compiler + class Baz[@specialized(Int) A]() extends IndexedSeq[A] { + def apply(i: Int) = ??? + def length: Int = 0 + } + + @Test + def test_SI9019 { + object Foo { + def mkBar = () => { + class Bar extends IndexedSeq[Int] { + def apply(i: Int) = ??? + def length: Int = 0 + } + new Bar + } + } + val bar = Foo.mkBar() + assertEquals("Bar", bar.stringPrefix) // Previously would have been outermost class, TraversableLikeTest + + val baz = new Baz[Int]() + assertEquals("TraversableLikeTest.Baz", baz.stringPrefix) // Make sure we don't see specialization $mcI$sp stuff + } +} |