@@ -97,7 +97,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
97
97
new ExprImpl (self, SpliceScope .getCurrent)
98
98
else self match
99
99
case TermTypeTest (self) => throw new Exception (" Expected an expression. This is a partially applied Term. Try eta-expanding the term first." )
100
- case _ => throw new Exception (" Expected a Term but was: " + self)
100
+ case _ => throw new Exception (" Expected a Term but was: " + Printer . TreeStructure .show( self) )
101
101
end extension
102
102
103
103
extension (self : Tree )
@@ -186,10 +186,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
186
186
187
187
object StatementTypeTest extends TypeTest [Tree , Statement ]:
188
188
def unapply (x : Tree ): Option [Statement & x.type ] = x match
189
- case _ : tpd.PatternTree => None
190
- case _ =>
191
- if x.isTerm then TermTypeTest .unapply(x)
192
- else DefinitionTypeTest .unapply(x)
189
+ case TermTypeTest (x : x.type ) => Some (x)
190
+ case DefinitionTypeTest (x : x.type ) => Some (x)
191
+ case ImportTypeTest (x : x.type ) => Some (x)
192
+ case ExportTypeTest (x : x.type ) => Some (x)
193
+ case _ => None
193
194
end StatementTypeTest
194
195
195
196
type Definition = tpd.MemberDef
@@ -1021,7 +1022,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
1021
1022
1022
1023
object TypeIdentTypeTest extends TypeTest [Tree , TypeIdent ]:
1023
1024
def unapply (x : Tree ): Option [TypeIdent & x.type ] = x match
1024
- case tpt : (tpd.Ident & x.type ) if tpt.isType => Some (tpt)
1025
+ case tpt : (tpd.Ident & x.type ) if tpt.isType && tpt.name != nme. WILDCARD => Some (tpt)
1025
1026
case _ => None
1026
1027
end TypeIdentTypeTest
1027
1028
@@ -1335,7 +1336,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
1335
1336
1336
1337
object WildcardTypeTreeTypeTest extends TypeTest [Tree , WildcardTypeTree ]:
1337
1338
def unapply (x : Tree ): Option [WildcardTypeTree & x.type ] = x match
1338
- case x : (tpd.Ident & x.type ) if x.name == nme.WILDCARD => Some (x)
1339
+ case x : (tpd.Ident & x.type ) if x.isType && x. name == nme.WILDCARD => Some (x)
1339
1340
case _ => None
1340
1341
end WildcardTypeTreeTypeTest
1341
1342
0 commit comments