File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -2932,7 +2932,11 @@ class JSCodeGen()(using genCtx: Context) {
2932
2932
case TYPEOF =>
2933
2933
// js.typeOf(arg)
2934
2934
val arg = genArgs1
2935
- genAsInstanceOf(js.JSUnaryOp (js.JSUnaryOp .typeof, arg), defn.StringType )
2935
+ val typeofExpr = arg match {
2936
+ case arg : js.JSGlobalRef => js.JSTypeOfGlobalRef (arg)
2937
+ case _ => js.JSUnaryOp (js.JSUnaryOp .typeof, arg)
2938
+ }
2939
+ js.AsInstanceOf (typeofExpr, jstpe.ClassType (jsNames.BoxedStringClass ))
2936
2940
2937
2941
case STRICT_EQ =>
2938
2942
// js.special.strictEquals(arg1, arg2)
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import dotty.tools.dotc.core._
11
11
import dotty .tools .dotc .transform .MegaPhase ._
12
12
import dotty .tools .dotc .transform .SymUtils ._
13
13
14
+ import dotty .tools .backend .sjs .JSDefinitions .jsdefn
15
+
14
16
/** Removes selects that would be compiled into GetStatic
15
17
* otherwise backend needs to be aware that some qualifiers need to be dropped.
16
18
* Similar transformation seems to be performed by flatten in nsc
@@ -31,6 +33,7 @@ class SelectStatic extends MiniPhase with IdentityDenotTransformer {
31
33
val tree1 =
32
34
if isStaticRef && ! tree.qualifier.symbol.isAllOf(JavaModule ) && ! tree.qualifier.isType then
33
35
if isPureExpr(tree.qualifier) then ref(sym)
36
+ else if ctx.settings.scalajs.value && sym.is(Module ) && sym.moduleClass.hasAnnotation(jsdefn.JSGlobalScopeAnnot ) then ref(sym)
34
37
else Block (List (tree.qualifier), ref(sym))
35
38
else tree
36
39
Original file line number Diff line number Diff line change @@ -1009,6 +1009,12 @@ object Build {
1009
1009
scalaJSLinkerConfig ~= { _.withSemantics(build.TestSuiteLinkerOptions .semantics _) },
1010
1010
scalaJSModuleInitializers in Test ++= build.TestSuiteLinkerOptions .moduleInitializers,
1011
1011
1012
+ jsEnvInput in Test := {
1013
+ val resourceDir = fetchScalaJSSource.value / " test-suite/js/src/test/resources"
1014
+ val f = (resourceDir / " NonNativeJSTypeTestNatives.js" ).toPath
1015
+ org.scalajs.jsenv.Input .Script (f) +: (jsEnvInput in Test ).value
1016
+ },
1017
+
1012
1018
managedSources in Compile ++= {
1013
1019
val dir = fetchScalaJSSource.value / " test-suite/js/src/main/scala"
1014
1020
val filter = (
@@ -1049,7 +1055,6 @@ object Build {
1049
1055
-- " ExportsTest.scala" // JS exports
1050
1056
-- " IterableTest.scala" // non-native JS classes
1051
1057
-- " JSExportStaticTest.scala" // JS exports
1052
- -- " JSNativeInPackage.scala" // #9785 tests fail due to js.typeOf(globalVar) being incorrect
1053
1058
-- " JSOptionalTest.scala" // non-native JS classes
1054
1059
-- " JSSymbolTest.scala" // non-native JS classes
1055
1060
-- " MiscInteropTest.scala" // non-native JS classes
You can’t perform that action at this time.
0 commit comments