From 30876fe2dd8cbe657a6cad6b11bbc34f10c29b36 Mon Sep 17 00:00:00 2001 From: Rex Kerr Date: Tue, 31 Mar 2015 14:56:53 -0700 Subject: SI-9019 TraversableLike stringPrefix broken for inner classes This version preserves outer class and object names but discards any part of the name after a `$` that does not start with an upper-case letter. When an integer literal occurs after a `$`, the prefix up to that point is dropped so that classes defined within methods appear as top-level. --- .../scala/collection/TraversableLikeTest.scala | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/junit/scala/collection/TraversableLikeTest.scala (limited to 'test/junit/scala/collection') 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 + } +} -- cgit v1.2.3