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.
add failing test: demo transparent inline can not see forwarders at t…
…yper At typer, when transparent inline methods are expanded, unroll forwarders are not yet generated. So if we define forwarders for the first time, in the same compilation unit that inlines a call to the forwarder, then it will fail. Perhaps we can detect this and suspend the unit, otherwise it would seem unreasonable complexity to generate forwarders in typer.
- Loading branch information
1 parent
4006af0
commit 8a1887c
Showing
6 changed files
with
82 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package a | ||
|
||
import scala.annotation.unroll | ||
|
||
// new project with a single file, first compile via Zinc | ||
object A { | ||
|
||
def foo(s: String, x: Int): String = s + x | ||
|
||
} |
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,8 @@ | ||
package b | ||
|
||
import a.* | ||
|
||
// Add a separate file in the same project as A, second compile via Zinc | ||
object B { | ||
transparent inline def caller = A.foo("abc", 2) | ||
} |
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,17 @@ | ||
package a | ||
import b.* | ||
|
||
import scala.annotation.unroll | ||
|
||
// modify A.scala and add a parameter to foo, and add C, third compile via Zinc | ||
object A { | ||
|
||
def foo(s: String, x: Int, @unroll b: Boolean = true): String = s + x + b | ||
|
||
} | ||
|
||
// C is the same compilation unit as A, and inlines B.caller, so its TASTy will see the forwarder | ||
// where the associated file came from source | ||
object C { | ||
val res = B.caller | ||
} |
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,28 @@ | ||
lazy val commonSettings = Seq( | ||
scalacOptions += "-experimental", | ||
) | ||
|
||
lazy val printSettings = Seq( | ||
scalacOptions += "-Yprint-tasty", | ||
) | ||
|
||
lazy val a_v1 = project.in(file("a_v1")) | ||
.settings(commonSettings) | ||
.settings( | ||
Compile / classDirectory := (ThisBuild / baseDirectory).value / "v2-input" | ||
) | ||
|
||
lazy val a_v2 = project.in(file("a_v2")) | ||
.settings(commonSettings) | ||
.settings(printSettings) | ||
.settings( | ||
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "v2-input", | ||
Compile / classDirectory := (ThisBuild / baseDirectory).value / "v3-input" | ||
) | ||
|
||
lazy val a_v3 = project.in(file("a_v3")) | ||
.settings(commonSettings) | ||
.settings( | ||
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "v3-input", | ||
Compile / classDirectory := (ThisBuild / baseDirectory).value / "v3-output" | ||
) |
11 changes: 11 additions & 0 deletions
11
sbt-test/tasty-compat/add-param-unroll2/project/DottyInjectedPlugin.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,11 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
object DottyInjectedPlugin extends AutoPlugin { | ||
override def requires = plugins.JvmPlugin | ||
override def trigger = allRequirements | ||
|
||
override val projectSettings = Seq( | ||
scalaVersion := sys.props("plugin.scalaVersion") | ||
) | ||
} |
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,8 @@ | ||
# compile library A via Zinc, with an initial file A defining method foo | ||
> a_v1/compile | ||
# compile library A via Zinc, for the second time, adding a new file that defines an inline | ||
# method B.caller, calling A.foo | ||
> a_v2/compile | ||
# compile library A via Zinc, for the third time, add a new parameter to A.foo, using @unroll to generate a forwarder | ||
# in the same file A.scala, define object C that inlines B.caller, it should succeed and resolve the new invisible forwarder | ||
> a_v3/compile |