Skip to content

Commit bc2e06d

Browse files
committed
Stop using IsXYZ extractors
1 parent c1e0e04 commit bc2e06d

File tree

18 files changed

+58
-54
lines changed

18 files changed

+58
-54
lines changed

tests/neg-macros/delegate-match-1/Macro_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ inline def f: Any = ${ fImpl }
66
private def fImpl(given qctx: QuoteContext): Expr[Unit] = {
77
import qctx.tasty.{_, given}
88
searchImplicit(('[A]).unseal.tpe) match {
9-
case IsImplicitSearchSuccess(x) =>
9+
case x: ImplicitSearchSuccess =>
1010
'{}
11-
case IsDivergingImplicit(x) => '{}
11+
case x: DivergingImplicit => '{}
1212
error("DivergingImplicit\n" + x.explanation, rootPosition)
1313
'{}
14-
case IsNoMatchingImplicits(x) =>
14+
case x: NoMatchingImplicits =>
1515
error("NoMatchingImplicits\n" + x.explanation, rootPosition)
1616
'{}
17-
case IsAmbiguousImplicits(x) =>
17+
case x: AmbiguousImplicits =>
1818
error("AmbiguousImplicits\n" + x.explanation, rootPosition)
1919
'{}
2020
}

tests/neg-macros/delegate-match-2/Macro_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ inline def f: Any = ${ fImpl }
66
private def fImpl(given qctx: QuoteContext): Expr[Unit] = {
77
import qctx.tasty.{_, given}
88
searchImplicit(('[A]).unseal.tpe) match {
9-
case IsImplicitSearchSuccess(x) =>
9+
case x: ImplicitSearchSuccess =>
1010
'{}
11-
case IsDivergingImplicit(x) => '{}
11+
case x: DivergingImplicit => '{}
1212
error("DivergingImplicit\n" + x.explanation, rootPosition)
1313
'{}
14-
case IsNoMatchingImplicits(x) =>
14+
case x: NoMatchingImplicits =>
1515
error("NoMatchingImplicits\n" + x.explanation, rootPosition)
1616
'{}
17-
case IsAmbiguousImplicits(x) =>
17+
case x: AmbiguousImplicits =>
1818
error("AmbiguousImplicits\n" + x.explanation, rootPosition)
1919
'{}
2020
}

tests/neg-macros/delegate-match-3/Macro_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ inline def f: Any = ${ fImpl }
66
private def fImpl(given qctx: QuoteContext): Expr[Unit] = {
77
import qctx.tasty.{_, given}
88
searchImplicit(('[A]).unseal.tpe) match {
9-
case IsImplicitSearchSuccess(x) =>
9+
case x: ImplicitSearchSuccess =>
1010
'{}
11-
case IsDivergingImplicit(x) => '{}
11+
case x: DivergingImplicit => '{}
1212
error("DivergingImplicit\n" + x.explanation, rootPosition)
1313
'{}
14-
case IsNoMatchingImplicits(x) =>
14+
case x: NoMatchingImplicits =>
1515
error("NoMatchingImplicits\n" + x.explanation, rootPosition)
1616
'{}
17-
case IsAmbiguousImplicits(x) =>
17+
case x: AmbiguousImplicits =>
1818
error("AmbiguousImplicits\n" + x.explanation, rootPosition)
1919
'{}
2020
}

tests/neg-macros/tasty-macro-assert-1/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object Asserts {
1818
val tree = cond.unseal
1919

2020
def isOps(tpe: TypeOrBounds): Boolean = tpe match {
21-
case IsTermRef(tpe) => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts
21+
case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts
2222
case _ => false
2323
}
2424

tests/neg-macros/tasty-macro-assert-2/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object Asserts {
1818
val tree = cond.unseal
1919

2020
def isOps(tpe: TypeOrBounds): Boolean = tpe match {
21-
case IsTermRef(tpe) => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts
21+
case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts
2222
case _ => false
2323
}
2424

tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ object Macros {
1414
val output = new TreeTraverser {
1515
override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = {
1616
tree match {
17-
case IsDefinition(tree @ DefDef(name, _, _, _, _)) =>
17+
case tree @ DefDef(name, _, _, _, _) =>
1818
buff.append(name)
1919
buff.append("\n")
2020
buff.append(tree.symbol.owner.tree.showExtractors)
2121
buff.append("\n\n")
22-
case IsDefinition(tree @ ValDef(name, _, _)) =>
22+
case tree @ ValDef(name, _, _) =>
2323
buff.append(name)
2424
buff.append("\n")
2525
buff.append(tree.symbol.owner.tree.showExtractors)

tests/run-macros/flops-rewrite-2/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ private class Rewriter(preTransform: List[Transformation[_]] = Nil, postTransfor
7676
import qctx.tasty.{_, given}
7777
class MapChildren extends TreeMap {
7878
override def transformTerm(tree: Term)(given ctx: Context): Term = tree match {
79-
case IsClosure(_) =>
79+
case _: Closure =>
8080
tree
81-
case IsInlined(_) | IsSelect(_) =>
81+
case _: Inlined | _: Select =>
8282
transformChildrenTerm(tree)
8383
case _ =>
8484
tree.tpe.widen match {
85-
case IsMethodType(_) | IsPolyType(_) =>
85+
case _: MethodType | _: PolyType =>
8686
transformChildrenTerm(tree)
8787
case _ =>
8888
tree.seal match {

tests/run-macros/flops-rewrite-3/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ private class Rewriter private (preTransform: List[Transformation] = Nil, postTr
112112
import qctx.tasty.{_, given}
113113
class MapChildren extends TreeMap {
114114
override def transformTerm(tree: Term)(given ctx: Context): Term = tree match {
115-
case IsClosure(_) =>
115+
case _: Closure =>
116116
tree
117-
case IsInlined(_) | IsSelect(_) =>
117+
case _: Inlined | _: Select =>
118118
transformChildrenTerm(tree)
119119
case _ =>
120120
tree.tpe.widen match {
121-
case IsMethodType(_) | IsPolyType(_) =>
121+
case _: MethodType | _: PolyType =>
122122
transformChildrenTerm(tree)
123123
case _ =>
124124
tree.seal match {

tests/run-macros/flops-rewrite/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ private class Rewriter(preTransform: Expr[Any] => Expr[Any], postTransform: Expr
5858
import qctx.tasty.{_, given}
5959
class MapChildren extends TreeMap {
6060
override def transformTerm(tree: Term)(given ctx: Context): Term = tree match {
61-
case IsClosure(_) =>
61+
case _: Closure =>
6262
tree
63-
case IsInlined(_) | IsSelect(_) =>
63+
case _: Inlined | _: Select =>
6464
transformChildrenTerm(tree)
6565
case _ =>
6666
tree.tpe.widen match {
67-
case IsMethodType(_) | IsPolyType(_) =>
67+
case _: MethodType | _: PolyType =>
6868
transformChildrenTerm(tree)
6969
case _ =>
7070
tree.seal match {

tests/run-macros/inferred-repeated-result/test_1.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ object Macros {
1111
val methods =
1212
tree.tpe.classSymbol.get.classMethods.map { m =>
1313
val name = m.show
14-
val IsDefDef(ddef) = m.tree
15-
val returnType = ddef.returnTpt.tpe.show
16-
s"$name : $returnType"
14+
m.tree match
15+
case ddef: DefDef =>
16+
val returnType = ddef.returnTpt.tpe.show
17+
s"$name : $returnType"
1718
}.sorted
1819

1920
methods.foldLeft('{}) { (res, m) => '{ $res; println(${m}) } }

tests/run-macros/tasty-custom-show/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ object Macros {
1717
// Use custom Show[_] here
1818
val printer = dummyShow
1919
tree match {
20-
case IsDefinition(tree @ DefDef(name, _, _, _, _)) =>
20+
case tree @ DefDef(name, _, _, _, _) =>
2121
buff.append(name)
2222
buff.append("\n")
2323
buff.append(printer.showTree(tree))
2424
buff.append("\n\n")
25-
case IsDefinition(tree @ ValDef(name, _, _)) =>
25+
case tree @ ValDef(name, _, _) =>
2626
buff.append(name)
2727
buff.append("\n")
2828
buff.append(printer.showTree(tree))

tests/run-macros/tasty-eval/quoted_1.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ object Macros {
2121
import qctx.tasty.{_, given}
2222

2323
e.unseal.tpe match {
24-
case IsTermRef(pre) if pre.termSymbol.isValDef =>
25-
val IsValDef(t) = pre.termSymbol.tree
26-
t.tpt.tpe match {
27-
case ConstantType(Constant(i: Int)) => Some(i)
28-
case _ => None
29-
}
24+
case pre: TermRef if pre.termSymbol.isValDef =>
25+
pre.termSymbol.tree match
26+
case t: ValDef =>
27+
t.tpt.tpe match {
28+
case ConstantType(Constant(i: Int)) => Some(i)
29+
case _ => None
30+
}
3031
case ConstantType(Constant(i: Int)) => Some(i)
3132
case _ => None
3233
}

tests/run-macros/tasty-extractors-3/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ object Macros {
1313
val buff = new StringBuilder
1414
val traverser = new TreeTraverser {
1515
override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = tree match {
16-
case IsTypeBoundsTree(tree) =>
16+
case tree: TypeBoundsTree =>
1717
buff.append(tree.tpe.showExtractors)
1818
buff.append("\n\n")
1919
traverseTreeChildren(tree)
20-
case IsTypeTree(tree) =>
20+
case tree: TypeTree =>
2121
buff.append(tree.tpe.showExtractors)
2222
buff.append("\n\n")
2323
traverseTreeChildren(tree)

tests/run-macros/tasty-macro-assert/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object Asserts {
1818
val tree = cond.unseal
1919

2020
def isOps(tpe: TypeOrBounds): Boolean = tpe match {
21-
case IsTermRef(tpe) => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts
21+
case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts
2222
case _ => false
2323
}
2424

tests/run-macros/tasty-seal-method/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object Asserts {
1212
x.unseal.underlyingArgument match {
1313
case Apply(fn, args) =>
1414
fn.tpe.widen match {
15-
case IsMethodType(_) =>
15+
case _: MethodType =>
1616
args.size match {
1717
case 0 => Expr.betaReduce(fn.etaExpand.seal.cast[() => Int])()
1818
case 1 => Expr.betaReduce(fn.etaExpand.seal.cast[Int => Int])('{0})

tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
2626
def interpretCall(inst: AbstractAny, sym: Symbol, args: List[AbstractAny]): Result = {
2727
// TODO
2828
// withLocalValue(`this`, inst) {
29-
val IsDefDef(ddef) = sym.tree
30-
val syms = ddef.paramss.headOption.getOrElse(Nil).map(_.symbol)
31-
withLocalValues(syms, args.map(LocalValue.valFrom(_))) {
32-
eval(ddef.rhs.get)
33-
}
29+
sym.tree match
30+
case ddef: DefDef =>
31+
val syms = ddef.paramss.headOption.getOrElse(Nil).map(_.symbol)
32+
withLocalValues(syms, args.map(LocalValue.valFrom(_))) {
33+
eval(ddef.rhs.get)
34+
}
3435
// }
3536
}
3637

@@ -42,11 +43,12 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
4243
case _ =>
4344
}
4445
val evaluatedArgs = argss.flatten.map(arg => LocalValue.valFrom(eval(arg)))
45-
val IsDefDef(ddef) = fn.symbol.tree
46-
val syms = ddef.paramss.headOption.getOrElse(Nil).map(_.symbol)
47-
withLocalValues(syms, evaluatedArgs) {
48-
eval(ddef.rhs.get)
49-
}
46+
fn.symbol.tree match
47+
case ddef: DefDef =>
48+
val syms = ddef.paramss.headOption.getOrElse(Nil).map(_.symbol)
49+
withLocalValues(syms, evaluatedArgs) {
50+
eval(ddef.rhs.get)
51+
}
5052
}
5153

5254
def interpretValGet(fn: Term): Result =
@@ -207,8 +209,8 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
207209

208210
private object Call {
209211
def unapply(arg: Tree): Option[(Term, List[TypeTree], List[List[Term]])] = arg match {
210-
case IsSelect(fn) => Some((fn, Nil, Nil))
211-
case IsIdent(fn) => Some((fn, Nil, Nil))
212+
case fn: Select => Some((fn, Nil, Nil))
213+
case fn: Ident => Some((fn, Nil, Nil))
212214
case Apply(Call(fn, targs, args1), args2) => Some((fn, targs, args1 :+ args2))
213215
case TypeApply(Call(fn, _, _), targs) => Some((fn, targs, Nil))
214216
case _ => None

tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpre
1717
// Best effort to try to create a proxy
1818
val sym = fn.symbol.owner
1919
if (sym.isClassDef) {
20-
val IsClassDef(tree) = sym.tree
20+
sym.tree match case tree: ClassDef =>
2121
val parentSymbols = tree.parents.tail.map(_.asInstanceOf[TypeTree].symbol).head
2222
import java.lang.reflect._
2323
val handler: InvocationHandler = new InvocationHandler() {

tests/run-with-compiler/tasty-comment-consumer/Test.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CommentConsumer extends TastyConsumer {
1414
object Traverser extends TreeTraverser {
1515

1616
override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = tree match {
17-
case IsDefinition(tree) =>
17+
case tree: Definition =>
1818
tree.symbol.comment match {
1919
case Some(com) => println(com.raw)
2020
case None => println()

0 commit comments

Comments
 (0)