Skip to content

Commit 3ff7f77

Browse files
Merge pull request #10258 from dotty-staging/remove-typerepr-seal
Remove TypeRepr.seal
2 parents aaec84d + 55c9017 commit 3ff7f77

File tree

9 files changed

+10
-13
lines changed

9 files changed

+10
-13
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2698,7 +2698,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
26982698
// After matching and doing all subtype checks, we have to approximate all the type bindings
26992699
// that we have found, seal them in a quoted.Type and add them to the result
27002700
def typeHoleApproximation(sym: Symbol) =
2701-
ctx1.gadt.approximation(sym, !sym.hasAnnotation(dotc.core.Symbols.defn.InternalQuotedPatterns_fromAboveAnnot)).asInstanceOf[qctx1.reflect.TypeRepr].seal
2701+
ctx1.gadt.approximation(sym, !sym.hasAnnotation(dotc.core.Symbols.defn.InternalQuotedPatterns_fromAboveAnnot)).asInstanceOf[qctx1.reflect.TypeRepr].asType
27022702
matchings.map { tup =>
27032703
Tuple.fromIArray(typeHoles.map(typeHoleApproximation).toArray.asInstanceOf[IArray[Object]]) ++ tup
27042704
}

library/src-bootstrapped/scala/quoted/ExprMap.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ trait ExprMap:
102102
transformTermChildren(tree, tpe)
103103
case _ if tree.isExpr =>
104104
type X
105-
val expr = tree.seal.asInstanceOf[Expr[X]]
106-
val t = tpe.seal.asInstanceOf[quoted.Type[X]]
105+
val expr = tree.asExpr.asInstanceOf[Expr[X]]
106+
val t = tpe.asType.asInstanceOf[Type[X]]
107107
transform(expr)(using qctx, t).unseal
108108
case _ =>
109109
transformTermChildren(tree, tpe)

library/src/scala/tasty/Reflection.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,9 +1767,6 @@ trait Reflection { reflection =>
17671767
/** Shows the tree as fully typed source code colored with ANSI */
17681768
def showAnsiColored: String
17691769

1770-
/** Convert `TypeRepr` to an `quoted.Type[_]` */
1771-
def seal: scala.quoted.Type[_]
1772-
17731770
/** Convert this `TypeRepr` to an `Type[?]`
17741771
*
17751772
* Usage:

tests/neg-macros/i8871.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted._
22
object Macro {
33
def impl[A : Type](using qctx: QuoteContext): Unit = {
44
import qctx.reflect._
5-
val tpe = TypeRepr.of[A].seal.asInstanceOf[Type[_ <: AnyRef]]
5+
val tpe = TypeRepr.of[A].asType.asInstanceOf[Type[_ <: AnyRef]]
66
'{ (a: ${tpe}) => ???} // error
77
}
88
}

tests/neg-macros/i8871b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted._
22
object Macro {
33
def impl[A : Type](using qctx: QuoteContext): Unit = {
44
import qctx.reflect._
5-
val tpe/*: Type[? <: AnyKind]*/ = TypeRepr.of[A].seal
5+
val tpe/*: Type[? <: AnyKind]*/ = TypeRepr.of[A].asType
66
'{ f[$tpe] } // error
77
}
88
def f[T <: AnyKind]: Unit = ()

tests/pos-macros/tasty-constant-type/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object Macro {
1212
val ConstantType(Constant.Int(v1)) = TypeRepr.of[A]
1313
val ConstantType(Constant.Int(v2)) = TypeRepr.of[B]
1414

15-
Literal(Constant.Int(v1 + v2)).tpe.seal match
15+
Literal(Constant.Int(v1 + v2)).tpe.asType match
1616
case '[t] => '{ null: AddInt[A, B] { type Out = t } }
1717
}
1818
}

tests/run-macros/i7887/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def myMacroImpl(a: quoted.Expr[_])(using qctx: quoted.QuoteContext) = {
22
import qctx.reflect._
33
def typed[A] = {
4-
implicit val t: quoted.Type[A] = a.unseal.tpe.widen.seal.asInstanceOf[quoted.Type[A]]
4+
implicit val t: quoted.Type[A] = a.unseal.tpe.widen.asType.asInstanceOf[quoted.Type[A]]
55
'{
66
type T = A
77
${a.unseal.asExprOf[T]}

tests/run-macros/refined-selectable-macro/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object Macro {
3838

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

9090
val r = rec(repr, Set.empty)
9191

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

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

0 commit comments

Comments
 (0)