Skip to content

Commit 0dbfdfe

Browse files
committed
wip
1 parent 7f1c537 commit 0dbfdfe

File tree

12 files changed

+20
-17
lines changed

12 files changed

+20
-17
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
398398
case New(_) | Closure(_, _, _) =>
399399
Pure
400400
case TypeApply(fn, _) =>
401-
if (fn.symbol.is(Erased) || fn.symbol == defn.QuotedTypeModule_apply || fn.symbol == defn.ScopeTypeModule_apply || fn.symbol == defn.Predef_classOf) Pure else exprPurity(fn)
401+
if (fn.symbol.is(Erased) || fn.symbol == defn.ScopeTypeModule_apply || fn.symbol == defn.Predef_classOf) Pure else exprPurity(fn)
402402
case Apply(fn, args) =>
403403
def isKnownPureOp(sym: Symbol) =
404404
sym.owner.isPrimitiveValueClass

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,6 @@ class Definitions {
680680
@tu lazy val QuotedExprModule_nullExpr: Symbol = QuotedExprModule.requiredMethod(nme.nullExpr)
681681
@tu lazy val QuotedExprModule_unitExpr: Symbol = QuotedExprModule.requiredMethod(nme.unitExpr)
682682

683-
// TODO remove
684-
@tu lazy val QuotedTypeModule_apply: Symbol = requiredModule("scala.quoted.Type").requiredMethod("apply")
685-
686683
@tu lazy val TastyReflectionClass: ClassSymbol = requiredClass("scala.tasty.Reflection")
687684

688685
@tu lazy val ScopeClass: ClassSymbol = requiredClass("scala.quoted.Scope")

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class ReifyQuotes extends MacroTransform {
128128
* core and splices as arguments.
129129
*/
130130
override protected def transformQuotation(body: Tree, quote: Tree)(using Context): Tree = {
131-
val isType = (quote.symbol eq defn.QuotedTypeModule_apply) || (quote.symbol eq defn.ScopeTypeModule_apply)
131+
val isType = quote.symbol eq defn.ScopeTypeModule_apply
132132
if (level > 0) {
133133
val body1 = nested(isQuote = true).transform(body)(using quoteContext)
134134
super.transformQuotation(body1, quote)
@@ -371,7 +371,7 @@ class ReifyQuotes extends MacroTransform {
371371
transform(tree)(using ctx.withSource(tree.source))
372372
else reporting.trace(i"Reifier.transform $tree at $level", show = true) {
373373
tree match {
374-
case Apply(Select(TypeApply(fn, (body: RefTree) :: Nil), _), _) if (fn.symbol == defn.QuotedTypeModule_apply || fn.symbol == defn.ScopeTypeModule_apply) && isCaptured(body.symbol, level + 1) =>
374+
case Apply(Select(TypeApply(fn, (body: RefTree) :: Nil), _), _) if fn.symbol == defn.ScopeTypeModule_apply && isCaptured(body.symbol, level + 1) =>
375375
// Optimization: avoid the full conversion when capturing `x`
376376
// in '{ x } to '{ ${x$1} } and go directly to `x$1`
377377
capturers(body.symbol)(body)

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ object Splicer {
141141
case Apply(Select(Apply(fn, quoted :: Nil), nme.apply), _) if fn.symbol == defn.InternalQuoted_exprQuote =>
142142
// OK
143143

144-
case TypeApply(fn, quoted :: Nil) if fn.symbol == defn.QuotedTypeModule_apply || fn.symbol == defn.ScopeTypeModule_apply =>
144+
case TypeApply(fn, quoted :: Nil) if fn.symbol == defn.ScopeTypeModule_apply =>
145145
// OK
146146

147147
case Literal(Constant(value)) =>
@@ -243,7 +243,7 @@ object Splicer {
243243
}
244244
interpretQuote(quoted1)
245245

246-
case Apply(Select(TypeApply(fn, quoted :: Nil), _), _) if fn.symbol == defn.QuotedTypeModule_apply || fn.symbol == defn.ScopeTypeModule_apply=>
246+
case Apply(Select(TypeApply(fn, quoted :: Nil), _), _) if fn.symbol == defn.ScopeTypeModule_apply =>
247247
interpretTypeQuote(quoted)
248248
case TypeApply(fn, quoted :: Nil) if fn.symbol == defn.ScopeTypeModule_apply =>
249249
interpretTypeQuote(quoted)

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ object SymUtils {
203203

204204
/** Is symbol a quote operation? */
205205
def isQuote(using Context): Boolean =
206-
self == defn.InternalQuoted_exprQuote || self == defn.QuotedTypeModule_apply || self == defn.ScopeTypeModule_apply
206+
self == defn.InternalQuoted_exprQuote || self == defn.ScopeTypeModule_apply
207207

208208
/** Is symbol a term splice operation? */
209209
def isExprSplice(using Context): Boolean =

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
528528
case New(_) | Closure(_, _, _) =>
529529
true
530530
case TypeApply(fn, _) =>
531-
if (fn.symbol.is(Erased) || fn.symbol == defn.QuotedTypeModule_apply || fn.symbol == defn.ScopeTypeModule_apply) true else apply(fn)
531+
if (fn.symbol.is(Erased) || fn.symbol == defn.ScopeTypeModule_apply) true else apply(fn)
532532
case Apply(fn, args) =>
533533
def isKnownPureOp(sym: Symbol) =
534534
sym.owner.isPrimitiveValueClass

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ trait QuotesAndSplices {
394394
val exprPt = pt.dealias match
395395
case AppliedType(tycon, arg :: Nil) =>
396396
if quoted.isType && tycon.isRef(defn.ScopeTypeClass) then arg
397-
else if tycon.isRef(defn.ScopeExprClass) then arg
397+
else if quoted.isTerm && tycon.isRef(defn.ScopeExprClass) then arg
398398
else NoType
399399
case _ => NoType
400400

library/src-bootstrapped/scala/quoted/Scope.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,13 @@ trait Scope extends Liftables, Unliftables { self =>
232232

233233

234234

235+
// tests/neg-staging/i6992.scala failed
236+
// tests/run-staging/i3876.scala failed
235237
// tests/run-staging/i4044b.scala failed
238+
// tests/run-staging/i4730.scala failed
239+
// tests/run-staging/i5247.scala failed
240+
// tests/run-staging/i6754.scala failed
236241
// tests/run-staging/multi-staging.scala failed
242+
// tests/run-staging/quote-nested-4.scala failed
237243
// tests/run-staging/staged-streams_1.scala failed
238244
// tests/run-staging/staged-tuples failed

tests/run-staging/i3876-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object Test {
1111
f
1212
}
1313

14-
def expr(using QuoteContext) = '{$f2($x)}
14+
def expr(using Scope) = '{$f2($x)}
1515
println(run(Expr.betaReduce(expr)))
1616
println(usingNewScope(Expr.betaReduce(expr).show)) // TODO improve printer
1717
}

tests/run-staging/i3876-c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Test {
1010
val f: (x: Int) => Int = x => x + x
1111
f
1212
}
13-
def expr(using QuoteContext) = '{$f3($x)}
13+
def expr(using Scope) = '{$f3($x)}
1414
println(run(Expr.betaReduce(expr)))
1515
println(usingNewScope(Expr.betaReduce(expr).show)) // TODO improve printer
1616
}

tests/run-staging/i3876.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ object Test {
99
def f(using s: Scope): s.Expr[Int => Int] = '{ (x: Int) => x + x }
1010

1111
println(run(Expr.betaReduce('{$f($x)})))
12-
println(usingNewScope(Expr.betaReduce(f)(x).show))
12+
println(usingNewScope(Expr.betaReduce('{$f($x)})))
1313
}
1414
}

tests/run-staging/quote-fun-app-1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ object Test {
1212
println(f(43))
1313
}
1414

15-
def f1(using s: Scope): s.Expr[Int => Int] = '{ (n: Int) => ${Expr.betaReduce('{$f2(n)})('n)} } // FIXME infer parameter type
16-
def f2(using s: Scope): s.Expr[Int => Int] = '{ (n: Int) => ${Expr.betaReduce('{$f3(n)})('n)} }
17-
def f3(using s: Scope): s.Expr[Int => Int] = '{ (n: Int) => ${Expr.betaReduce('{$f4(n)})('n)} }
15+
def f1(using s: Scope): s.Expr[Int => Int] = '{ (n: Int) => ${Expr.betaReduce('{$f2(n)})} } // FIXME infer parameter type
16+
def f2(using s: Scope): s.Expr[Int => Int] = '{ (n: Int) => ${Expr.betaReduce('{$f3(n)})} }
17+
def f3(using s: Scope): s.Expr[Int => Int] = '{ (n: Int) => ${Expr.betaReduce('{$f4(n)})} }
1818
def f4(using s: Scope): s.Expr[Int => Int] = '{ (n: Int) => n }
1919
}

0 commit comments

Comments
 (0)