Skip to content

Commit 259824e

Browse files
committed
[nomerge] Scala classes ending in $ get a signature
Classes ending in `$` did not get a ScalaSignature by mistake. They were filtered out by the name-based test that is supposed to identify module classes. This fix is already in 2.13.x, part of 3aea776.
1 parent e72ab5a commit 259824e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
501501
*/
502502
def getAnnotPickle(jclassName: String, sym: Symbol): Option[AnnotationInfo] = {
503503
currentRun.symData get sym match {
504-
case Some(pickle) if !nme.isModuleName(newTermName(jclassName)) =>
504+
case Some(pickle) if !sym.isModuleClass =>
505505
val scalaAnnot = {
506506
val sigBytes = ScalaSigBytes(pickle.bytes.take(pickle.writeIndex))
507507
AnnotationInfo(sigBytes.sigAnnot, Nil, (nme.bytes, sigBytes) :: Nil)

test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import scala.tools.asm.Opcodes._
99
import scala.tools.partest.ASMConverters._
1010
import scala.tools.testing.BytecodeTesting
1111
import scala.tools.testing.BytecodeTesting._
12+
import scala.collection.JavaConverters._
1213

1314
@RunWith(classOf[JUnit4])
1415
class BytecodeTest extends BytecodeTesting {
@@ -195,4 +196,12 @@ class BytecodeTest extends BytecodeTesting {
195196
val List(ExceptionHandler(_, _, _, desc)) = m.handlers
196197
assert(desc == None, desc)
197198
}
199+
200+
@Test
201+
def classesEndingInDollarHaveSignature(): Unit = {
202+
// A name-based test in the backend prevented classes ending in $ from getting a Scala signature
203+
val code = "class C$"
204+
val c = compileClass(code)
205+
assertEquals(c.attrs.asScala.toList.map(_.`type`).sorted, List("ScalaInlineInfo", "ScalaSig"))
206+
}
198207
}

0 commit comments

Comments
 (0)