Skip to content

Commit 3433e3f

Browse files
committed
(doesn't work) Attempt to use a semantic name for JUnit bootstrappers.
1 parent 9f6d249 commit 3433e3f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

compiler/src/dotty/tools/backend/sjs/JUnitBootstrappers.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Contexts._
1010
import Decorators._
1111
import Flags._
1212
import Names._
13+
import NameKinds._
1314
import NameOps._
1415
import Phases._
1516
import Scopes._
@@ -146,15 +147,9 @@ class JUnitBootstrappers extends MiniPhase {
146147

147148
val junitdefn = jsdefn.junit
148149

149-
/* The name of the boostrapper module. It is derived from the test class name by
150-
* appending a specific suffix string mandated "by spec". It will indeed also be
151-
* computed as such at run-time by the Scala.js JUnit Runtime support. Therefore,
152-
* it must *not* be a dotc semantic name.
153-
*/
154-
val bootstrapperName = (testClass.name ++ "$scalajs$junit$bootstrapper").toTermName
155-
156150
val owner = testClass.owner
157-
val moduleSym = ctx.newCompleteModuleSymbol(owner, bootstrapperName,
151+
val moduleSym = ctx.newCompleteModuleSymbol(owner,
152+
ScalaJSJUnitBoostrapperName(testClass.name.toTermName),
158153
Synthetic, Synthetic,
159154
List(defn.ObjectType, junitdefn.BootstrapperType), newScope,
160155
coord = testClass.span, assocFile = testClass.assocFile).entered

compiler/src/dotty/tools/dotc/core/NameKinds.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ object NameKinds {
367367
val ModuleClassName: SuffixNameKind = new SuffixNameKind(OBJECTCLASS, "$", optInfoString = "ModuleClass")
368368
val ImplMethName: SuffixNameKind = new SuffixNameKind(IMPLMETH, "$")
369369
val AdaptedClosureName: SuffixNameKind = new SuffixNameKind(ADAPTEDCLOSURE, "$adapted") { override def definesNewName = true }
370+
val ScalaJSJUnitBoostrapperName: SuffixNameKind = new SuffixNameKind(SCALAJSJUNITBOOTSTRAPPER, "$scalajs$junit$bootstrapper") { override def definesNewName = true } // the string is semantically meaningful
370371

371372
/** A name together with a signature. Used in Tasty trees. */
372373
object SignedName extends NameKind(SIGNED) {

compiler/src/dotty/tools/dotc/core/NameTags.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ object NameTags extends TastyFormat.NameTags {
3636
final val IMPLMETH = 32 // Used to define methods in implementation classes
3737
// (can probably be removed).
3838

39+
final val SCALAJSJUNITBOOTSTRAPPER = 33 // Suffix for the bootstrapper module of a Scala.js JUnit test class
40+
3941
def nameTagToString(tag: Int): String = tag match {
4042
case UTF8 => "UTF8"
4143
case QUALIFIED => "QUALIFIED"
@@ -59,6 +61,8 @@ object NameTags extends TastyFormat.NameTags {
5961
case ADAPTEDCLOSURE => "ADAPTEDCLOSURE"
6062
case OBJECTCLASS => "OBJECTCLASS"
6163

64+
case SCALAJSJUNITBOOTSTRAPPER => "SCALAJSJUNITBOOTSTRAPPER"
65+
6266
case SIGNED => "SIGNED"
6367
}
6468
}

0 commit comments

Comments
 (0)