Skip to content

Commit 97c1284

Browse files
committed
Add test for reflect Symbol.isSuperAccessor
1 parent d6d898f commit 97c1284

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
method SyncIterator$$super$next
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import scala.quoted.*
2+
import scala.tasty.inspector.*
3+
4+
@main def Test = {
5+
// Artefact of the current test infrastructure
6+
// TODO improve infrastructure to avoid needing this code on each test
7+
val classpath = dotty.tools.dotc.util.ClasspathFromClassloader(this.getClass.getClassLoader).split(java.io.File.pathSeparator).find(_.contains("runWithCompiler")).get
8+
val allTastyFiles = dotty.tools.io.Path(classpath).walkFilter(_.extension == "tasty").map(_.toString).toList
9+
val tastyFiles = allTastyFiles.filter(_.contains("SyncIterator"))
10+
11+
TastyInspector.inspectTastyFiles(tastyFiles)(new MyInspector)
12+
}
13+
14+
class MyInspector extends Inspector:
15+
16+
override def inspect(using Quotes)(tastys: List[Tasty[quotes.type]]): Unit =
17+
import quotes.reflect.*
18+
class Traverser extends TreeTraverser:
19+
override def traverseTree(tree: Tree)(owner: Symbol) =
20+
tree match
21+
case tree: DefDef if tree.symbol.isSuperAccessor =>
22+
println(tree.symbol)
23+
case _ =>
24+
super.traverseTree(tree)(owner)
25+
end Traverser
26+
27+
val traverser = new Traverser
28+
tastys.foreach { tasty =>
29+
traverser.traverseTree(tasty.ast)(tasty.ast.symbol)
30+
}
31+
32+
33+
trait IntIterator {
34+
def next: Int
35+
def drop(n: Int): Unit
36+
}
37+
trait SyncIterator extends IntIterator {
38+
abstract override def next: Int = super.next
39+
}

0 commit comments

Comments
 (0)