forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scala#17344: Make implicit references to this above dynamic impor…
…ts explicit. Implicit references to the `this` of an outer class are made explicit by the typer, and they need to be for `explicitOuter` to do its job correctly. When we desugar a `js.dynamicImport`, we move the code inside a synthetic inner class. If it contains implicit references to an enclosing class, we must make them explicit at that point.
- Loading branch information
Showing
3 changed files
with
73 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
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
29 changes: 29 additions & 0 deletions
29
...st-require-multi-modules/org/scalajs/testsuite/jsinterop/SJSDynamicImportTestScala3.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,29 @@ | ||
package org.scalajs.testsuite.jsinterop | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Test | ||
|
||
import org.scalajs.junit.async._ | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation.* | ||
|
||
class SJSDynamicImportTestScala3 { | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
@Test def implicitThisReferenceInDynamicImport_Issue17344(): AsyncResult = await { | ||
class Foo() { | ||
def foo(): Int = 1 | ||
} | ||
class Bar(foo: Foo) { | ||
def bar(): js.Promise[Int] = js.dynamicImport(foo.foo()) | ||
} | ||
|
||
val bar = new Bar(new Foo()) | ||
val promise = bar.bar() | ||
|
||
promise.toFuture.map { r => | ||
assertEquals(1, r) | ||
} | ||
} | ||
} |