Skip to content

Remove TypeRepr.seal #10258

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

Merged
merged 1 commit into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2698,7 +2698,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
// After matching and doing all subtype checks, we have to approximate all the type bindings
// that we have found, seal them in a quoted.Type and add them to the result
def typeHoleApproximation(sym: Symbol) =
ctx1.gadt.approximation(sym, !sym.hasAnnotation(dotc.core.Symbols.defn.InternalQuotedPatterns_fromAboveAnnot)).asInstanceOf[qctx1.reflect.TypeRepr].seal
ctx1.gadt.approximation(sym, !sym.hasAnnotation(dotc.core.Symbols.defn.InternalQuotedPatterns_fromAboveAnnot)).asInstanceOf[qctx1.reflect.TypeRepr].asType
matchings.map { tup =>
Tuple.fromIArray(typeHoles.map(typeHoleApproximation).toArray.asInstanceOf[IArray[Object]]) ++ tup
}
Expand Down
4 changes: 2 additions & 2 deletions library/src-bootstrapped/scala/quoted/ExprMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ trait ExprMap:
transformTermChildren(tree, tpe)
case _ if tree.isExpr =>
type X
val expr = tree.seal.asInstanceOf[Expr[X]]
val t = tpe.seal.asInstanceOf[quoted.Type[X]]
val expr = tree.asExpr.asInstanceOf[Expr[X]]
val t = tpe.asType.asInstanceOf[Type[X]]
transform(expr)(using qctx, t).unseal
case _ =>
transformTermChildren(tree, tpe)
Expand Down
3 changes: 0 additions & 3 deletions library/src/scala/tasty/Reflection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1767,9 +1767,6 @@ trait Reflection { reflection =>
/** Shows the tree as fully typed source code colored with ANSI */
def showAnsiColored: String

/** Convert `TypeRepr` to an `quoted.Type[_]` */
def seal: scala.quoted.Type[_]

/** Convert this `TypeRepr` to an `Type[?]`
*
* Usage:
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i8871.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted._
object Macro {
def impl[A : Type](using qctx: QuoteContext): Unit = {
import qctx.reflect._
val tpe = TypeRepr.of[A].seal.asInstanceOf[Type[_ <: AnyRef]]
val tpe = TypeRepr.of[A].asType.asInstanceOf[Type[_ <: AnyRef]]
'{ (a: ${tpe}) => ???} // error
}
}
2 changes: 1 addition & 1 deletion tests/neg-macros/i8871b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted._
object Macro {
def impl[A : Type](using qctx: QuoteContext): Unit = {
import qctx.reflect._
val tpe/*: Type[? <: AnyKind]*/ = TypeRepr.of[A].seal
val tpe/*: Type[? <: AnyKind]*/ = TypeRepr.of[A].asType
'{ f[$tpe] } // error
}
def f[T <: AnyKind]: Unit = ()
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-macros/tasty-constant-type/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Macro {
val ConstantType(Constant.Int(v1)) = TypeRepr.of[A]
val ConstantType(Constant.Int(v2)) = TypeRepr.of[B]

Literal(Constant.Int(v1 + v2)).tpe.seal match
Literal(Constant.Int(v1 + v2)).tpe.asType match
case '[t] => '{ null: AddInt[A, B] { type Out = t } }
}
}
2 changes: 1 addition & 1 deletion tests/run-macros/i7887/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def myMacroImpl(a: quoted.Expr[_])(using qctx: quoted.QuoteContext) = {
import qctx.reflect._
def typed[A] = {
implicit val t: quoted.Type[A] = a.unseal.tpe.widen.seal.asInstanceOf[quoted.Type[A]]
implicit val t: quoted.Type[A] = a.unseal.tpe.widen.asType.asInstanceOf[quoted.Type[A]]
'{
type T = A
${a.unseal.asExprOf[T]}
Expand Down
4 changes: 2 additions & 2 deletions tests/run-macros/refined-selectable-macro/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object Macro {

def tupleElem(name: String, info: TypeRepr): Expr[Any] = {
val nameExpr = Expr(name)
info.seal match { case '[t] =>
info.asType match { case '[t] =>
Expr.ofTupleFromSeq(Seq(nameExpr, '{ $s.selectDynamic($nameExpr).asInstanceOf[t] }))
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ object Macro {

val r = rec(repr, Set.empty)

val refinementType = r.foldLeft(TypeRepr.of[T])((acc, e) => Refinement(acc, e._1, e._2)).seal
val refinementType = r.foldLeft(TypeRepr.of[T])((acc, e) => Refinement(acc, e._1, e._2)).asType

refinementType match { case '[t] =>
'{ $newRecord($s.toArray.map(e => e.asInstanceOf[(String, Any)])).asInstanceOf[t] }
Expand Down