-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle some explicit paths in quotes #8113
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ import dotty.tools.dotc.core.Contexts._ | |
import dotty.tools.dotc.core.Decorators._ | ||
import dotty.tools.dotc.core.Flags._ | ||
import dotty.tools.dotc.core.quoted._ | ||
import dotty.tools.dotc.core.Mode | ||
import dotty.tools.dotc.core.NameKinds._ | ||
import dotty.tools.dotc.core.StagingContext._ | ||
import dotty.tools.dotc.core.StdNames._ | ||
|
@@ -49,7 +50,10 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( | |
case annot => transform(annot.tree)(given annotCtx) | ||
} | ||
checkLevel(super.transform(tree)) | ||
case _ => checkLevel(super.transform(tree)) | ||
case _ => | ||
val ctx1 = if tree.isType then ctx.addMode(Mode.Type) else ctx | ||
given Context = ctx1 | ||
checkLevel(super.transform(tree)) | ||
} | ||
|
||
/** Transform quoted trees while maintaining phase correctness */ | ||
|
@@ -100,7 +104,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( | |
case Some(tpRef) => tpRef | ||
case _ => tree | ||
} | ||
case _: TypeTree | _: AppliedTypeTree | _: Apply | _: TypeApply | _: UnApply | Select(_, OuterSelectName(_, _)) => | ||
case _: TypeTree | _: AppliedTypeTree | _: Apply | _: UnApply | Select(_, OuterSelectName(_, _)) => | ||
tree.withType(checkTp(tree.tpe)) | ||
case _: ValOrDefDef | _: Bind => | ||
tree.symbol.info = checkTp(tree.symbol.info) | ||
|
@@ -179,6 +183,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( | |
case tp: TypeRef => | ||
if levelOf(sym).getOrElse(0) < level then tryHeal(sym, tp, pos) | ||
else None | ||
case _: TermRef if ctx.mode.is(Mode.Type) && levelOf(sym).getOrElse(0) >= level => None | ||
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. Will it be an issue, if it's used in pattern matching, e.g. |
||
case _ => | ||
levelError(sym, tp, pos, "") | ||
else if (!sym.owner.isStaticOwner) // non-top level class reference that is phase inconsistent | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ object Unpickler { | |
|
||
type PickledQuote = List[String] | ||
type PickledExprArgs = Seq[Seq[Any] => ((QuoteContext ?=> Expr[Any]) | Type[_])] | ||
type PickledTypeArgs = Seq[Seq[Any] => Type[_]] | ||
type PickledTypeArgs = Seq[Seq[Any] => ((QuoteContext ?=> Expr[Any]) | Type[_])] | ||
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. Can we simplify to only keep 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. Yes, but there are some bootstrapping constraints. |
||
|
||
/** Unpickle `repr` which represents a pickled `Expr` tree, | ||
* replacing splice nodes with `args` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
import scala.quoted._ | ||
import scala.quoted.matching._ | ||
|
||
class M { | ||
type E | ||
} | ||
|
||
def f[T: Type](using QuoteContext) = | ||
summonExpr[M] match | ||
case Some('{ $mm : $tt }) => | ||
'{ | ||
val m = $mm | ||
${ val b: m.type = | ||
m // error | ||
??? | ||
} | ||
} | ||
|
||
|
||
def g[T](using Type[T]) = ??? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
import scala.quoted._ | ||
import scala.quoted.matching._ | ||
|
||
class M { | ||
type E | ||
} | ||
|
||
def f(using QuoteContext): Expr[Any] = | ||
val mm: Expr[M] = ??? | ||
'{ | ||
val m: M = $mm | ||
type ME = m.E | ||
${ g[ME](using '[ME]) } | ||
${ g[m.E](using '[ME]) } | ||
${ g[ME](using '[m.E]) } | ||
${ g[m.E](using '[m.E]) } | ||
// ${ g[ME] } // FIXME | ||
// ${ g[m.E] } // FIXME | ||
${ g(using '[ME]) } | ||
${ g(using '[m.E]) } | ||
} | ||
|
||
|
||
def g[T](using Type[T]) = ??? |
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 ignore
TypeApply
?