-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Fix #19528: Actually remove Dynamic from interfaces of nati…
…ve JS classes." to LTS (#20866) Backports #19536 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
tests/sjs-junit/test/org/scalajs/testsuite/jsinterop/CustomDynamicTestScala3.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.scalajs.testsuite.jsinterop | ||
|
||
import scala.language.dynamics | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Test | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation.* | ||
|
||
class CustomDynamicTestScala3 { | ||
import CustomDynamicTestScala3.* | ||
|
||
@Test | ||
def testCustomDynamicClass_Issue19528(): Unit = { | ||
val obj = new CustomDynamicClass() | ||
|
||
assertEquals(false, obj.hasOwnProperty("foo")) | ||
obj.foo = "bar" | ||
assertEquals("bar", obj.foo) | ||
assertEquals(true, obj.hasOwnProperty("foo")) | ||
} | ||
|
||
@Test | ||
def testCustomDynamicTrait_Issue19528(): Unit = { | ||
val obj = new js.Object().asInstanceOf[CustomDynamicTrait] | ||
|
||
assertEquals(false, obj.hasOwnProperty("foo")) | ||
obj.foo = "bar" | ||
assertEquals("bar", obj.foo) | ||
assertEquals(true, obj.hasOwnProperty("foo")) | ||
} | ||
} | ||
|
||
object CustomDynamicTestScala3 { | ||
@js.native | ||
@JSGlobal("Object") | ||
class CustomDynamicClass extends js.Any with Dynamic { | ||
@JSBracketAccess | ||
def selectDynamic(name: String): js.Any = js.native | ||
@JSBracketAccess | ||
def updateDynamic(name: String)(value: js.Any): Unit = js.native | ||
|
||
@JSBracketCall | ||
def applyDynamic(name: String)(args: js.Any*): js.Any = js.native | ||
} | ||
|
||
@js.native | ||
trait CustomDynamicTrait extends js.Any with Dynamic { | ||
@JSBracketAccess | ||
def selectDynamic(name: String): js.Any = js.native | ||
@JSBracketAccess | ||
def updateDynamic(name: String)(value: js.Any): Unit = js.native | ||
|
||
@JSBracketCall | ||
def applyDynamic(name: String)(args: js.Any*): js.Any = js.native | ||
} | ||
} |