Skip to content

Fix #10222: Move scala.quoted.internal to scala.quoted.internal #10281

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

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki force-pushed the move-quote-internals-to-scala.quoted.internal branch from 6652ddc to 4a511b4 Compare November 11, 2020 11:34
@nicolasstucki nicolasstucki force-pushed the move-quote-internals-to-scala.quoted.internal branch from 4a511b4 to 57c4cf3 Compare November 11, 2020 12:16
Split `QuoteContextInternal` into `QuoteUnpickler` and `QuoteMatching`.
Also make sure that `QuoteContext` must extend `QuoteUnpickler` and `QuoteMatching`
@nicolasstucki nicolasstucki linked an issue Nov 11, 2020 that may be closed by this pull request
@nicolasstucki nicolasstucki force-pushed the move-quote-internals-to-scala.quoted.internal branch from b7a366a to a3affa7 Compare November 11, 2020 13:33
@nicolasstucki nicolasstucki changed the title Move scala.quoted.internal into the library Fix #10222: Move scala.quoted.internal to scala.quoted.internal Nov 11, 2020
@nicolasstucki nicolasstucki marked this pull request as ready for review November 11, 2020 14:55
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -323,10 +323,10 @@ object Splicer {
}

private def interpretQuote(tree: Tree)(implicit env: Env): Object =
new scala.quoted.internal.Expr(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuoteContextImpl.scopeId)
new dotty.tools.dotc.quoted.ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuoteContextImpl.scopeId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new dotty.tools.dotc.quoted.ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuoteContextImpl.scopeId)
new quoted.ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuoteContextImpl.scopeId)


private def interpretTypeQuote(tree: Tree)(implicit env: Env): Object =
new scala.quoted.internal.Type(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuoteContextImpl.scopeId)
new dotty.tools.dotc.quoted.TypeImpl(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuoteContextImpl.scopeId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new dotty.tools.dotc.quoted.TypeImpl(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuoteContextImpl.scopeId)
new quoted.TypeImpl(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuoteContextImpl.scopeId)

@@ -71,7 +72,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
case _ => false
def asExpr: scala.quoted.Expr[Any] =
if self.isExpr then
new scala.quoted.internal.Expr(self, QuoteContextImpl.this.hashCode)
new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode)
new ExprImpl(self, QuoteContextImpl.this.hashCode)

@@ -315,11 +316,11 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
object TermMethodsImpl extends TermMethods:
extension (self: Term):
def seal: scala.quoted.Expr[Any] =
if self.isExpr then new scala.quoted.internal.Expr(self, QuoteContextImpl.this.hashCode)
if self.isExpr then new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.isExpr then new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode)
if self.isExpr then new ExprImpl(self, QuoteContextImpl.this.hashCode)

else throw new Exception("Cannot seal a partially applied Term. Try eta-expanding the term first.")

def sealOpt: Option[scala.quoted.Expr[Any]] =
if self.isExpr then Some(new scala.quoted.internal.Expr(self, QuoteContextImpl.this.hashCode))
if self.isExpr then Some(new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.isExpr then Some(new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode))
if self.isExpr then Some(new ExprImpl(self, QuoteContextImpl.this.hashCode))

@@ -1002,7 +1003,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern

object TypeTree extends TypeTreeModule:
def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeTree =
tp.asInstanceOf[scala.quoted.internal.Type].typeTree
tp.asInstanceOf[dotty.tools.dotc.quoted.TypeImpl].typeTree
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tp.asInstanceOf[dotty.tools.dotc.quoted.TypeImpl].typeTree
tp.asInstanceOf[TypeImpl].typeTree

@@ -1571,7 +1572,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern

object TypeRepr extends TypeReprModule:
def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeRepr =
tp.asInstanceOf[scala.quoted.internal.Type].typeTree.tpe
tp.asInstanceOf[dotty.tools.dotc.quoted.TypeImpl].typeTree.tpe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tp.asInstanceOf[dotty.tools.dotc.quoted.TypeImpl].typeTree.tpe
tp.asInstanceOf[TypeImpl].typeTree.tpe

@@ -1608,7 +1609,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
def seal: scala.quoted.Type[_] = self.asType

def asType: scala.quoted.Type[?] =
new scala.quoted.internal.Type(Inferred(self), QuoteContextImpl.this.hashCode)
new dotty.tools.dotc.quoted.TypeImpl(Inferred(self), QuoteContextImpl.this.hashCode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new dotty.tools.dotc.quoted.TypeImpl(Inferred(self), QuoteContextImpl.this.hashCode)
new TypeImpl(Inferred(self), QuoteContextImpl.this.hashCode)

@@ -2623,11 +2624,11 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern

def unpickleExpr[T](pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.QuoteContext) => scala.quoted.Expr[?]): scala.quoted.Expr[T] =
val tree = PickledQuotes.unpickleTerm(pickled, typeHole, termHole)(using reflect.rootContext)
new scala.quoted.internal.Expr(tree, hash).asInstanceOf[scala.quoted.Expr[T]]
new dotty.tools.dotc.quoted.ExprImpl(tree, hash).asInstanceOf[scala.quoted.Expr[T]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new dotty.tools.dotc.quoted.ExprImpl(tree, hash).asInstanceOf[scala.quoted.Expr[T]]
new ExprImpl(tree, hash).asInstanceOf[scala.quoted.Expr[T]]


def unpickleType[T <: AnyKind](pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.QuoteContext) => scala.quoted.Expr[?]): scala.quoted.Type[T] =
val tree = PickledQuotes.unpickleTypeTree(pickled, typeHole, termHole)(using reflect.rootContext)
new scala.quoted.internal.Type(tree, hash).asInstanceOf[scala.quoted.Type[T]]
new dotty.tools.dotc.quoted.TypeImpl(tree, hash).asInstanceOf[scala.quoted.Type[T]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new dotty.tools.dotc.quoted.TypeImpl(tree, hash).asInstanceOf[scala.quoted.Type[T]]
new TypeImpl(tree, hash).asInstanceOf[scala.quoted.Type[T]]

@nicolasstucki
Copy link
Contributor Author

I'll clean up those paths later. I may still change something in the compiler implementation.

@nicolasstucki nicolasstucki merged commit b4d7084 into scala:master Nov 11, 2020
@nicolasstucki nicolasstucki deleted the move-quote-internals-to-scala.quoted.internal branch November 11, 2020 15:48
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move scala.internal.quoted to scala.quoted.internal?
3 participants