Skip to content

Commit 50f5a43

Browse files
committed
Perpare to move blackbox inlining after typer
1 parent b40e33d commit 50f5a43

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ class ScalaSettings extends Settings.SettingGroup {
183183
val Yinstrument: Setting[Boolean] = BooleanSetting("-Yinstrument", "Add instrumentation code that counts allocations and closure creations.")
184184
val YinstrumentDefs: Setting[Boolean] = BooleanSetting("-Yinstrument-defs", "Add instrumentation code that counts method calls; needs -Yinstrument to be set, too.")
185185

186+
// TODO Remove. Added to help bootstrappting this change.
187+
val YinlineBlackboxAfterTyper: Setting[Boolean] = BooleanSetting("-Yinline-blackbox-after-typer", "")
188+
186189
/** Dottydoc specific settings */
187190
val siteRoot: Setting[String] = StringSetting(
188191
"-siteroot",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted._
2+
3+
object Macros {
4+
5+
inline def blackbox: Int = ${one}
6+
7+
transparent inline def whitebox: Int = ${one}
8+
9+
private def one(using QuoteContext): Expr[Int] = Expr(1)
10+
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.quoted._
2+
import Macros._
3+
4+
object Test {
5+
def main(args: Array[String]): Unit = {
6+
val a: Int = blackbox
7+
val b: 1 = whitebox
8+
9+
assert(a == 1)
10+
assert(b == 1)
11+
}
12+
}

tests/run/whitebox-inline.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import scala.quoted._
2+
3+
object Test {
4+
def main(args: Array[String]): Unit = {
5+
val a: Int = blackbox
6+
val b: 1 = whitebox
7+
8+
assert(a == 1)
9+
assert(b == 1)
10+
}
11+
12+
inline def blackbox: Int = 1
13+
14+
transparent inline def whitebox: Int = 1
15+
16+
}

0 commit comments

Comments
 (0)