Skip to content

Commit ca01392

Browse files
committed
Remove support -scala-output-version with quotes
1 parent a5e32da commit ca01392

File tree

15 files changed

+9
-184
lines changed

15 files changed

+9
-184
lines changed

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

-2
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,7 @@ class Definitions {
827827

828828

829829
@tu lazy val QuoteUnpicklerClass: ClassSymbol = requiredClass("scala.quoted.runtime.QuoteUnpickler")
830-
@tu lazy val QuoteUnpickler_unpickleExpr: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleExpr")
831830
@tu lazy val QuoteUnpickler_unpickleExprV2: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleExprV2")
832-
@tu lazy val QuoteUnpickler_unpickleType: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleType")
833831
@tu lazy val QuoteUnpickler_unpickleTypeV2: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleTypeV2")
834832

835833
@tu lazy val QuoteMatchingClass: ClassSymbol = requiredClass("scala.quoted.runtime.QuoteMatching")

compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object PickledQuotes {
5050
/** `typeHole`/`types` argument of `QuoteUnpickler.{unpickleExpr,unpickleExprV2,unpickleType,unpickleTypeV2}` */
5151
enum TypeHole:
5252
/** `termHole` argument of `QuoteUnpickler.{unpickleExpr, unpickleType}`.
53-
* From code compiled with Scala 3.0.x and 3.1.x or with -scala-output-version 3.0 and 3.1
53+
* From code compiled with Scala 3.0.x and 3.1.x.
5454
* Note: For `unpickleType` it will always be `null`.
5555
*/
5656
case V1(evalHole: Null | ((Int, Seq[scala.quoted.Type[?]]) => scala.quoted.Type[?]))
@@ -65,7 +65,7 @@ object PickledQuotes {
6565

6666
enum ExprHole:
6767
/** `termHole` argument of `QuoteUnpickler.{unpickleExpr, unpickleType}`.
68-
* From code compiled with Scala 3.0.x and 3.1.x or with -scala-output-version 3.0 and 3.1
68+
* From code compiled with Scala 3.0.x and 3.1.x.
6969
* Note: For `unpickleType` it will always be `null`.
7070
*/
7171
case V1(evalHole: Null | ((Int, Seq[ExprHole.ArgV1], scala.quoted.Quotes) => scala.quoted.Expr[?]))

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

+6-36
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,6 @@ object PickleQuotes {
291291
* this closure is always applied directly to the actual context and the BetaReduce phase removes it.
292292
*/
293293
def pickleAsTasty() = {
294-
295-
val unpickleV1 = ctx.scalaRelease <= Release3_1
296-
297294
val pickleQuote = PickledQuotes.pickleQuote(body)
298295
val pickledQuoteStrings = pickleQuote match
299296
case x :: Nil => Literal(Constant(x))
@@ -306,26 +303,8 @@ object PickleQuotes {
306303

307304
// This and all closures in typeSplices are removed by the BetaReduce phase
308305
val types =
309-
if unpickleV1 then
310-
if typeSplices.isEmpty then Literal(Constant(null)) // keep pickled quote without contents as small as possible
311-
else
312-
Lambda(
313-
MethodType(
314-
List(nme.idx, nme.contents).map(name => UniqueName.fresh(name).toTermName),
315-
List(defn.IntType, defn.SeqType.appliedTo(defn.AnyType)),
316-
defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)),
317-
args => {
318-
val cases = typeSplices.map { case (splice, idx) =>
319-
CaseDef(Literal(Constant(idx)), EmptyTree, splice)
320-
}
321-
cases match
322-
case CaseDef(_, _, rhs) :: Nil => rhs
323-
case _ => Match(args(0).annotated(New(ref(defn.UncheckedAnnot.typeRef))), cases)
324-
}
325-
)
326-
else // if unpickleV2 then
327-
if typeSplices.isEmpty then Literal(Constant(null)) // keep pickled quote without contents as small as possible
328-
else SeqLiteral(typeSplices.map(_._1), TypeTree(defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)))
306+
if typeSplices.isEmpty then Literal(Constant(null)) // keep pickled quote without contents as small as possible
307+
else SeqLiteral(typeSplices.map(_._1), TypeTree(defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)))
329308

330309
// This and all closures in termSplices are removed by the BetaReduce phase
331310
val termHoles =
@@ -341,12 +320,7 @@ object PickleQuotes {
341320
val defn.FunctionOf(argTypes, defn.FunctionOf(quotesType :: _, _, _, _), _, _) = splice.tpe
342321
val rhs = {
343322
val spliceArgs = argTypes.zipWithIndex.map { (argType, i) =>
344-
val argi = args(1).select(nme.apply).appliedTo(Literal(Constant(i)))
345-
if unpickleV1 && argType.derivesFrom(defn.QuotedExprClass) then
346-
val argType1 = defn.FunctionType(1).appliedTo(defn.QuotesClass.typeRef, argType)
347-
argi.asInstance(argType1).select(nme.apply).appliedTo(args(2))
348-
else
349-
argi.asInstance(argType)
323+
args(1).select(nme.apply).appliedTo(Literal(Constant(i))).asInstance(argType)
350324
}
351325
val Block(List(ddef: DefDef), _) = splice
352326
// TODO: beta reduce inner closure? Or wait until BetaReduce phase?
@@ -363,14 +337,10 @@ object PickleQuotes {
363337
val quotedType = quoteClass.typeRef.appliedTo(originalTp)
364338
val lambdaTpe = MethodType(defn.QuotesClass.typeRef :: Nil, quotedType)
365339
val unpickleMeth =
366-
if unpickleV1 then
367-
if isType then defn.QuoteUnpickler_unpickleType
368-
else defn.QuoteUnpickler_unpickleExpr
369-
else // if unpickleV2 then
370-
if isType then defn.QuoteUnpickler_unpickleTypeV2
371-
else defn.QuoteUnpickler_unpickleExprV2
340+
if isType then defn.QuoteUnpickler_unpickleTypeV2
341+
else defn.QuoteUnpickler_unpickleExprV2
372342
val unpickleArgs =
373-
if isType && !unpickleV1 then List(pickledQuoteStrings, types)
343+
if isType then List(pickledQuoteStrings, types)
374344
else List(pickledQuoteStrings, types, termHoles)
375345
quotes
376346
.asInstance(defn.QuoteUnpicklerClass.typeRef)

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,7 @@ class Splicing extends MacroTransform:
135135
val hole = tpd.Hole(false, holeIdx, Nil, ref(qual), TypeTree(tp))
136136
typeHoles.put(qual.symbol, hole)
137137
hole
138-
val rhs =
139-
if ctx.scalaRelease <= Release3_1 then
140-
val secondHoleIdx = numHoles
141-
numHoles += 1
142-
TypeBoundsTree(hole, cpy.Hole(hole)(idx = secondHoleIdx))
143-
else hole
144-
cpy.TypeDef(tree)(rhs = rhs)
138+
cpy.TypeDef(tree)(rhs = hole)
145139
case Apply(Select(Apply(TypeApply(fn,_), List(code)),nme.apply),List(quotes))
146140
if fn.symbol == defn.QuotedRuntime_exprQuote =>
147141
super.transform(tree)(using quoteContext)

sbt-test/scala3-compat/macros-forward-3.0/app/App.scala

-17
This file was deleted.

sbt-test/scala3-compat/macros-forward-3.0/build.sbt

-14
This file was deleted.

sbt-test/scala3-compat/macros-forward-3.0/lib/Macro.scala

-20
This file was deleted.

sbt-test/scala3-compat/macros-forward-3.0/project/DottyInjectedPlugin.scala

-11
This file was deleted.

sbt-test/scala3-compat/macros-forward-3.0/test

-1
This file was deleted.

tests/disabled/pos-macros/forwardCompat-3.0/Macro_1_r3.0.scala

-20
This file was deleted.

tests/disabled/pos-macros/forwardCompat-3.0/Test_2_c3.0.2.scala

-15
This file was deleted.

tests/disabled/pos-macros/forwardCompat-3.0/why.md

-3
This file was deleted.

tests/disabled/pos-macros/forwardCompat-3.1/Macro_1_r3.1.scala

-20
This file was deleted.

tests/disabled/pos-macros/forwardCompat-3.1/Test_2_c3.1.0.scala

-15
This file was deleted.

tests/disabled/pos-macros/forwardCompat-3.1/why.md

-1
This file was deleted.

0 commit comments

Comments
 (0)