-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove scala.internal.quoted.LiftedExpr #6793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import typer.Implicits.SearchFailureType | |
|
||
import scala.collection.mutable | ||
import dotty.tools.dotc.core.Annotations.Annotation | ||
import dotty.tools.dotc.core.Names._ | ||
import dotty.tools.dotc.core.StdNames._ | ||
import dotty.tools.dotc.core.quoted._ | ||
import dotty.tools.dotc.transform.TreeMapWithStages._ | ||
|
@@ -71,6 +72,8 @@ class ReifyQuotes extends MacroTransform { | |
|
||
override def phaseName: String = ReifyQuotes.name | ||
|
||
override def allowsImplicitSearch: Boolean = true | ||
|
||
override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { | ||
tree match { | ||
case tree: RefTree if !ctx.inInlineMethod => | ||
|
@@ -199,8 +202,29 @@ class ReifyQuotes extends MacroTransform { | |
} | ||
|
||
private def pickledQuote(body: Tree, splices: List[Tree], originalTp: Type, isType: Boolean)(implicit ctx: Context) = { | ||
def pickleAsValue[T](value: T) = | ||
ref(defn.Unpickler_liftedExpr).appliedToType(originalTp.widen).appliedTo(Literal(Constant(value))) | ||
|
||
def liftedValue[T](value: T, name: TermName, qctx: Tree) = | ||
ref(defn.LiftableModule).select(name).select("toExpr".toTermName).appliedTo(Literal(Constant(value))).appliedTo(qctx) | ||
|
||
def pickleAsValue[T](value: T) = { | ||
val qctx = ctx.typer.inferImplicitArg(defn.QuoteContextType, body.span) | ||
if (qctx.tpe.isInstanceOf[SearchFailureType]) | ||
ctx.error(ctx.typer.missingArgMsg(qctx, defn.QuoteContextType, ""), ctx.source.atSpan(body.span)) | ||
value match { | ||
case null => ref(defn.QuotedExprModule).select("nullExpr".toTermName).appliedTo(qctx) | ||
case _: Unit => ref(defn.QuotedExprModule).select("unitExpr".toTermName).appliedTo(qctx) | ||
case _: Boolean => liftedValue(value, "Liftable_Boolean_delegate".toTermName, qctx) | ||
case _: Byte => liftedValue(value, "Liftable_Byte_delegate".toTermName, qctx) | ||
case _: Short => liftedValue(value, "Liftable_Short_delegate".toTermName, qctx) | ||
case _: Int => liftedValue(value, "Liftable_Int_delegate".toTermName, qctx) | ||
case _: Long => liftedValue(value, "Liftable_Long_delegate".toTermName, qctx) | ||
case _: Float => liftedValue(value, "Liftable_Float_delegate".toTermName, qctx) | ||
case _: Double => liftedValue(value, "Liftable_Double_delegate".toTermName, qctx) | ||
case _: Char => liftedValue(value, "Liftable_Char_delegate".toTermName, qctx) | ||
case _: String => liftedValue(value, "Liftable_String_delegate".toTermName, qctx) | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need special compiler support for lifting primitives? Or it's for backward-compatibility. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not need it anymore. |
||
def pickleAsTasty() = { | ||
val meth = | ||
if (isType) ref(defn.Unpickler_unpickleType).appliedToType(originalTp) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package scala | ||
|
||
package object quoted { | ||
|
||
def run[T](expr: given QuoteContext => Expr[T]) given (toolbox: Toolbox): T = | ||
throw new Exception("Non bootsrapped library") | ||
|
||
def withQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T = | ||
throw new Exception("Non bootsrapped library") | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ trait TypeOrBoundsOps extends Core { | |
|
||
object Type { | ||
|
||
def apply(clazz: Class[_])(implicit ctx: Context): Type = kernel.Type_apply(clazz) | ||
|
||
object IsConstantType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the two neg-with-compiler tests are disabled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those tests where testing scope extrusion detection through an euristic which happens to no work anymore. I will work on more reliable mechanism for scope extrusion detection later. |
||
/** Matches any ConstantType and returns it */ | ||
def unapply(tpe: TypeOrBounds)(implicit ctx: Context): Option[ConstantType] = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
Type
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the encoding for a
classOf[T]