Skip to content

Commit 114f778

Browse files
committed
Fix scala-js#2027: Call genBCode.bTypes.initializeCoreBTypes().
This requires extensive compatibility magic due to the rather peculiar history of the "path" towards that method. See the comments in the code for the details.
1 parent f34ad74 commit 114f778

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

compiler/src/main/scala/org/scalajs/core/compiler/Compat210Component.scala

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package org.scalajs.core.compiler
77

8+
import scala.language.implicitConversions
9+
810
import scala.collection.mutable
911

1012
import scala.tools.nsc._
@@ -58,6 +60,48 @@ trait Compat210Component {
5860
}
5961
}
6062

63+
/* global.genBCode.bTypes.initializeCoreBTypes()
64+
*
65+
* This one has a very particular history:
66+
* - in 2.10.x, no genBCode in global
67+
* - in 2.11.{0-1}, there is genBCode but it has no bTypes member
68+
* - In 2.11.{2-5}, there is genBCode.bTypes, but it has no
69+
* initializeCoreBTypes (it was actually typo'ed as intializeCoreBTypes!)
70+
* - In 2.11.6+, including 2.12, we finally have
71+
* genBCode.bTypes.initializeCoreBTypes
72+
* - As of 2.12.0-M4, it is mandatory to call that method from GenJSCode.run()
73+
*/
74+
75+
object LowPrioGenBCodeCompat {
76+
object genBCode {
77+
object bTypes {
78+
def initializeCoreBTypes(): Unit = ()
79+
}
80+
}
81+
}
82+
83+
def initializeCoreBTypesCompat(): Unit = {
84+
import LowPrioGenBCodeCompat._
85+
86+
{
87+
import global._
88+
89+
import LowPrioGenBCodeCompat.genBCode._
90+
91+
{
92+
import genBCode._
93+
94+
import LowPrioGenBCodeCompat.genBCode.bTypes._
95+
96+
{
97+
import bTypes._
98+
99+
initializeCoreBTypes()
100+
}
101+
}
102+
}
103+
}
104+
61105
// ErasedValueType has a different encoding
62106

63107
implicit final class ErasedValueTypeCompat(self: global.ErasedValueType) {

compiler/src/main/scala/org/scalajs/core/compiler/GenJSCode.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ abstract class GenJSCode extends plugins.PluginComponent
161161

162162
override def run(): Unit = {
163163
scalaPrimitives.init()
164+
initializeCoreBTypesCompat()
164165
jsPrimitives.init()
165166
super.run()
166167
}

0 commit comments

Comments
 (0)