Skip to content

Commit e87ace2

Browse files
Merge pull request #9194 from dotty-staging/remove-seal-from-compiler-interface
Remove seal from compiler interface
2 parents da41b1a + 6453e9c commit e87ace2

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,16 +1901,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
19011901
def QuotedType_unseal(self: scala.quoted.Type[?])(using ctx: Context): TypeTree =
19021902
PickledQuotes.quotedTypeToTree(self)
19031903

1904-
def QuotedExpr_seal(self: Term)(using ctx: Context): Option[scala.quoted.Expr[Any]] = self.tpe.widen match {
1905-
case _: Types.MethodType | _: Types.PolyType => None
1906-
case _ => Some(new scala.internal.quoted.Expr(self, compilerId))
1907-
}
1908-
1909-
/** Convert `Type` to an `quoted.Type[?]` */
1910-
def QuotedType_seal(self: Type)(using ctx: Context): scala.quoted.Type[?] = {
1911-
val dummySpan = ctx.owner.span // FIXME
1912-
new scala.internal.quoted.Type(tpd.TypeTree(self).withSpan(dummySpan), compilerId)
1913-
}
19141904

19151905
/////////////////
19161906
// DEFINITIONS //

library/src/scala/tasty/Reflection.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,15 @@ 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))
631633

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

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

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

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,12 +1446,6 @@ trait CompilerInterface {
14461446
/** View this expression `quoted.Type[T]` as a `TypeTree` */
14471447
def QuotedType_unseal(self: scala.quoted.Type[_])(using ctx: Context): TypeTree
14481448

1449-
/** Convert `Term` to an `quoted.Expr[Any]` if the term is a valid expression */
1450-
def QuotedExpr_seal(self: Term)(using ctx: Context): Option[scala.quoted.Expr[Any]]
1451-
1452-
/** Convert `Type` to an `quoted.Type[_]` */
1453-
def QuotedType_seal(self: Type)(using ctx: Context): scala.quoted.Type[_]
1454-
14551449

14561450
/////////////////
14571451
// DEFINITIONS //

0 commit comments

Comments
 (0)