@@ -23,8 +23,6 @@ import scala.reflect.TypeTest
2323
2424object QuotesImpl {
2525
26- type ScopeId = Int
27-
2826 def apply ()(using Context ): Quotes =
2927 new QuotesImpl
3028
@@ -34,11 +32,6 @@ object QuotesImpl {
3432 if ctx.settings.color.value == " always" then TreeAnsiCode .show(tree)
3533 else TreeCode .show(tree)
3634
37- // TODO Explore more fine grained scope ids.
38- // This id can only differentiate scope extrusion from one compiler instance to another.
39- def scopeId (using Context ): ScopeId =
40- ctx.outersIterator.toList.last.hashCode()
41-
4235}
4336
4437class QuotesImpl private (using val ctx : Context ) extends Quotes , QuoteUnpickler , QuoteMatching :
@@ -81,10 +74,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
8174 end CompilationInfo
8275
8376 extension (expr : Expr [Any ])
84- def asTerm : Term =
85- val exprImpl = expr.asInstanceOf [ExprImpl ]
86- exprImpl.checkScopeId(QuotesImpl .this .hashCode)
87- exprImpl.tree
77+ def asTerm : Term = expr.asInstanceOf [ExprImpl ].tree
8878 end extension
8979
9080 type Tree = tpd.Tree
@@ -105,7 +95,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
10595 case _ => false
10696 def asExpr : scala.quoted.Expr [Any ] =
10797 if self.isExpr then
108- new ExprImpl (self, QuotesImpl . this .hashCode, SpliceScope .getCurrent)
98+ new ExprImpl (self, SpliceScope .getCurrent)
10999 else self match
110100 case TermTypeTest (self) => throw new Exception (" Expected an expression. This is a partially applied Term. Try eta-expanding the term first." )
111101 case _ => throw new Exception (" Expected a Term but was: " + self)
@@ -372,11 +362,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
372362 given TermMethods : TermMethods with
373363 extension (self : Term )
374364 def seal : scala.quoted.Expr [Any ] =
375- if self.isExpr then new ExprImpl (self, QuotesImpl . this .hashCode, SpliceScope .getCurrent)
365+ if self.isExpr then new ExprImpl (self, SpliceScope .getCurrent)
376366 else throw new Exception (" Cannot seal a partially applied Term. Try eta-expanding the term first." )
377367
378368 def sealOpt : Option [scala.quoted.Expr [Any ]] =
379- if self.isExpr then Some (new ExprImpl (self, QuotesImpl . this .hashCode, SpliceScope .getCurrent))
369+ if self.isExpr then Some (new ExprImpl (self, SpliceScope .getCurrent))
380370 else None
381371
382372 def tpe : TypeRepr = self.tpe
@@ -1666,7 +1656,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
16661656 def seal : scala.quoted.Type [_] = self.asType
16671657
16681658 def asType : scala.quoted.Type [? ] =
1669- new TypeImpl (Inferred (self), QuotesImpl . this .hashCode, SpliceScope .getCurrent)
1659+ new TypeImpl (Inferred (self), SpliceScope .getCurrent)
16701660
16711661 def =:= (that : TypeRepr ): Boolean = self =:= that
16721662 def <:< (that : TypeRepr ): Boolean = self <:< that
@@ -2877,11 +2867,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
28772867
28782868 def unpickleExpr [T ](pickled : String | List [String ], typeHole : (Int , Seq [Any ]) => scala.quoted.Type [? ], termHole : (Int , Seq [Any ], scala.quoted.Quotes ) => scala.quoted.Expr [? ]): scala.quoted.Expr [T ] =
28792869 val tree = PickledQuotes .unpickleTerm(pickled, typeHole, termHole)
2880- new ExprImpl (tree, hash, SpliceScope .getCurrent).asInstanceOf [scala.quoted.Expr [T ]]
2870+ new ExprImpl (tree, SpliceScope .getCurrent).asInstanceOf [scala.quoted.Expr [T ]]
28812871
28822872 def unpickleType [T <: AnyKind ](pickled : String | List [String ], typeHole : (Int , Seq [Any ]) => scala.quoted.Type [? ], termHole : (Int , Seq [Any ], scala.quoted.Quotes ) => scala.quoted.Expr [? ]): scala.quoted.Type [T ] =
28832873 val tree = PickledQuotes .unpickleTypeTree(pickled, typeHole, termHole)
2884- new TypeImpl (tree, hash, SpliceScope .getCurrent).asInstanceOf [scala.quoted.Type [T ]]
2874+ new TypeImpl (tree, SpliceScope .getCurrent).asInstanceOf [scala.quoted.Type [T ]]
28852875
28862876 object ExprMatch extends ExprMatchModule :
28872877 def unapply [TypeBindings <: Tuple , Tup <: Tuple ](scrutinee : scala.quoted.Expr [Any ])(using pattern : scala.quoted.Expr [Any ]): Option [Tup ] =
@@ -2948,7 +2938,4 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
29482938 }
29492939 }
29502940
2951- private [this ] val hash = QuotesImpl .scopeId(using ctx)
2952- override def hashCode : Int = hash
2953-
29542941end QuotesImpl
0 commit comments