@@ -11,15 +11,17 @@ private trait ScalaJSClassData[A] extends js.Object {
11
11
val isRawJSType : scala.Boolean = js.native
12
12
13
13
def isInstance (obj : Object ): scala.Boolean = js.native
14
- def getFakeInstance ( ): Object = js.native
14
+ def isAssignableFrom ( that : ScalaJSClassData [_] ): scala. Boolean = js.native
15
15
16
16
def getSuperclass (): Class [_ >: A ] = js.native
17
17
def getComponentType (): Class [_] = js.native
18
18
19
19
def newArrayOfThisClass (dimensions : js.Array [Int ]): AnyRef = js.native
20
20
}
21
21
22
- final class Class [A ] private (data : ScalaJSClassData [A ]) extends Object {
22
+ final class Class [A ] private (data0 : Object ) extends Object {
23
+ private val data : ScalaJSClassData [A ] =
24
+ data0.asInstanceOf [ScalaJSClassData [A ]]
23
25
24
26
override def toString (): String = {
25
27
(if (isInterface()) " interface " else
@@ -30,30 +32,7 @@ final class Class[A] private (data: ScalaJSClassData[A]) extends Object {
30
32
data.isInstance(obj)
31
33
32
34
def isAssignableFrom (that : Class [_]): scala.Boolean =
33
- if (this .isPrimitive || that.isPrimitive) {
34
- /* This differs from the JVM specification to mimic the behavior of
35
- * runtime type tests of primitive numeric types.
36
- */
37
- (this eq that) || {
38
- if (this eq classOf [scala.Short ])
39
- (that eq classOf [scala.Byte ])
40
- else if (this eq classOf [scala.Int ])
41
- (that eq classOf [scala.Byte ]) || (that eq classOf [scala.Short ])
42
- else if (this eq classOf [scala.Float ])
43
- (that eq classOf [scala.Byte ]) || (that eq classOf [scala.Short ]) ||
44
- (that eq classOf [scala.Int ])
45
- else if (this eq classOf [scala.Double ])
46
- (that eq classOf [scala.Byte ]) || (that eq classOf [scala.Short ]) ||
47
- (that eq classOf [scala.Int ]) || (that eq classOf [scala.Float ])
48
- else
49
- false
50
- }
51
- } else {
52
- this .isInstance(that.getFakeInstance())
53
- }
54
-
55
- private def getFakeInstance (): Object =
56
- data.getFakeInstance()
35
+ this .data.isAssignableFrom(that.data)
57
36
58
37
def isInterface (): scala.Boolean =
59
38
data.isInterface
0 commit comments