Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit 7b1c5d5

Browse files
authored
Merge pull request #104 from tanishiking/reflective-call-throw
Throw an exception when reflective proxy not found
2 parents c2b2ec7 + bbad4a9 commit 7b1c5d5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Diff for: build.sbt

-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ lazy val `scalajs-test-suite` = project
226226

227227
lazy val IgnoredTestNames: Set[String] = {
228228
Set(
229-
// reflective call: should be throw an exception when reflective proxy not found
230-
"org.scalajs.testsuite.compiler.WasPublicBeforeTyperTestScala2",
231229
// javaLangClassGetNameRenamedThroughSemantics failed: org.junit.ComparisonFailure:
232230
// expected:<[renamed.test.]Class> but was:<[org.scalajs.testsuite.compiler.ReflectionTest$RenamedTest]Class>
233231
"org.scalajs.testsuite.compiler.ReflectionTest",

Diff for: wasm/src/main/scala/ir2wasm/HelperFunctions.scala

+10-3
Original file line numberDiff line numberDiff line change
@@ -1650,9 +1650,16 @@ object HelperFunctions {
16501650
instrs += I32_ADD
16511651
instrs += LOCAL_SET(i)
16521652
}
1653-
// method not found, trap
1654-
// TODO? maybe we should throw an exception
1655-
instrs += UNREACHABLE
1653+
// throw new TypeError("...")
1654+
instrs ++= ctx.getConstantStringInstr("TypeError")
1655+
instrs += CALL(WasmFunctionName.jsGlobalRefGet)
1656+
instrs += CALL(WasmFunctionName.jsNewArray)
1657+
// Originally, exception is thrown from JS saying e.g. "obj2.z1__ is not a function"
1658+
instrs ++= ctx.getConstantStringInstr("Method not found")
1659+
instrs += CALL(WasmFunctionName.jsArrayPush)
1660+
instrs += CALL(WasmFunctionName.jsNew)
1661+
instrs += EXTERN_CONVERT_ANY
1662+
instrs += THROW(ctx.exceptionTagName)
16561663

16571664
fctx.buildAndAddToContext()
16581665
}

0 commit comments

Comments
 (0)