@@ -23,8 +23,6 @@ import scala.reflect.TypeTest
23
23
24
24
object QuotesImpl {
25
25
26
- type ScopeId = Int
27
-
28
26
def apply ()(using Context ): Quotes =
29
27
new QuotesImpl
30
28
@@ -34,11 +32,6 @@ object QuotesImpl {
34
32
if ctx.settings.color.value == " always" then TreeAnsiCode .show(tree)
35
33
else TreeCode .show(tree)
36
34
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
-
42
35
}
43
36
44
37
class QuotesImpl private (using val ctx : Context ) extends Quotes , QuoteUnpickler , QuoteMatching :
@@ -81,10 +74,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
81
74
end CompilationInfo
82
75
83
76
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
88
78
end extension
89
79
90
80
type Tree = tpd.Tree
@@ -105,7 +95,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
105
95
case _ => false
106
96
def asExpr : scala.quoted.Expr [Any ] =
107
97
if self.isExpr then
108
- new ExprImpl (self, QuotesImpl . this .hashCode, SpliceScope .getCurrent)
98
+ new ExprImpl (self, SpliceScope .getCurrent)
109
99
else self match
110
100
case TermTypeTest (self) => throw new Exception (" Expected an expression. This is a partially applied Term. Try eta-expanding the term first." )
111
101
case _ => throw new Exception (" Expected a Term but was: " + self)
@@ -372,11 +362,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
372
362
given TermMethods : TermMethods with
373
363
extension (self : Term )
374
364
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)
376
366
else throw new Exception (" Cannot seal a partially applied Term. Try eta-expanding the term first." )
377
367
378
368
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))
380
370
else None
381
371
382
372
def tpe : TypeRepr = self.tpe
@@ -1666,7 +1656,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
1666
1656
def seal : scala.quoted.Type [_] = self.asType
1667
1657
1668
1658
def asType : scala.quoted.Type [? ] =
1669
- new TypeImpl (Inferred (self), QuotesImpl . this .hashCode, SpliceScope .getCurrent)
1659
+ new TypeImpl (Inferred (self), SpliceScope .getCurrent)
1670
1660
1671
1661
def =:= (that : TypeRepr ): Boolean = self =:= that
1672
1662
def <:< (that : TypeRepr ): Boolean = self <:< that
@@ -2877,11 +2867,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
2877
2867
2878
2868
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 ] =
2879
2869
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 ]]
2881
2871
2882
2872
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 ] =
2883
2873
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 ]]
2885
2875
2886
2876
object ExprMatch extends ExprMatchModule :
2887
2877
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
2948
2938
}
2949
2939
}
2950
2940
2951
- private [this ] val hash = QuotesImpl .scopeId(using ctx)
2952
- override def hashCode : Int = hash
2953
-
2954
2941
end QuotesImpl
0 commit comments