Skip to content

Commit 85f1bb3

Browse files
committed
Implement Tree.seal to the library
1 parent d9832f6 commit 85f1bb3

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,11 +1887,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
18871887
// QUOTED SEAL/UNSEAL //
18881888
////////////////////////
18891889

1890-
def QuotedExpr_seal(self: Term)(using ctx: Context): Option[scala.quoted.Expr[Any]] = self.tpe.widen match {
1891-
case _: Types.MethodType | _: Types.PolyType => None
1892-
case _ => Some(new scala.internal.quoted.Expr(self, compilerId))
1893-
}
1894-
18951890
/** Convert `Type` to an `quoted.Type[?]` */
18961891
def QuotedType_seal(self: Type)(using ctx: Context): scala.quoted.Type[?] = {
18971892
val dummySpan = ctx.owner.span // FIXME

library/src/scala/tasty/Reflection.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,16 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
621621

622622
/** Convert `Term` to an `quoted.Expr[Any]` if the term is a valid expression or throws */
623623
def seal(using ctx: Context): scala.quoted.Expr[Any] =
624-
internal.QuotedExpr_seal(self).getOrElse {
624+
sealOpt.getOrElse {
625625
throw new Exception("Cannot seal a partially applied Term. Try eta-expanding the term first.")
626626
}
627627

628628
/** Convert `Term` to an `quoted.Expr[Any]` if the term is a valid expression */
629629
def sealOpt(using ctx: Context): Option[scala.quoted.Expr[Any]] =
630-
internal.QuotedExpr_seal(self)
630+
self.tpe.widen match {
631+
case _: MethodType | _: PolyType => None
632+
case _ => Some(new scala.internal.quoted.Expr(self, internal.compilerId))
633+
}
631634

632635
/** Type of this term */
633636
def tpe(using ctx: Context): Type = internal.Term_tpe(self)
@@ -1616,7 +1619,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
16161619

16171620
/** Convert `Type` to an `quoted.Type[_]` */
16181621
def seal(using ctx: Context): scala.quoted.Type[_] =
1619-
internal.QuotedType_seal(self)
1622+
new scala.internal.quoted.Type(Inferred(self), internal.compilerId)
16201623

16211624
/** Is `self` type the same as `that` type?
16221625
* This is the case iff `self <:< that` and `that <:< self`.

library/src/scala/tasty/reflect/CompilerInterface.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,17 +1432,6 @@ trait CompilerInterface {
14321432
def Flags_Package: Flags
14331433

14341434

1435-
////////////////////////
1436-
// QUOTED SEAL/UNSEAL //
1437-
////////////////////////
1438-
1439-
/** Convert `Term` to an `quoted.Expr[Any]` if the term is a valid expression */
1440-
def QuotedExpr_seal(self: Term)(using ctx: Context): Option[scala.quoted.Expr[Any]]
1441-
1442-
/** Convert `Type` to an `quoted.Type[_]` */
1443-
def QuotedType_seal(self: Type)(using ctx: Context): scala.quoted.Type[_]
1444-
1445-
14461435
/////////////////
14471436
// DEFINITIONS //
14481437
/////////////////

0 commit comments

Comments
 (0)