blob: bbad123d01e4ccbcc364b391295273c4f8f7444a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import scala.tools.partest.DirectTest
import scala.tools.nsc.util.stringFromStream
object Test extends DirectTest {
override def extraSettings: String = "-usejavacp -Yshow:typer"
override def code = """
package foo.bar
class Bippy {
type BippyType <: {
def showdefTestMemberType1: Unit
}
def showdefTestMemberClass1 = 5
class Boppity {
def showdefTestMemberClass2 = 5
class Boo {
def showdefTestMemberClass3 = 5
}
object Boo {
def showdefTestMemberObject1 = "abc"
}
}
}
object Bippy {
type BippyType <: {
def showdefTestMemberType2: Unit
}
def showdefTestMemberObject2 = "abc"
}
"""
override def show(): Unit = {
val classes = List("Bippy", "Bippy#BippyType", "Bippy.BippyType", "Bippy#Boppity", "Bippy#Boppity#Boo")
val objects = List("Bippy", "Bippy#Boppity#Boo")
def interesting(line: String) = (line contains "def showdefTestMember") || (line startsWith "<<-- ")
def run(args: String*) = slurp(args: _*).lines filter interesting foreach println
classes foreach (x => run("-Xshow-class", x))
objects foreach (x => run("-Xshow-object", x))
}
// slurp the compilation result
def slurp(args: String*): String = stringFromStream { stream =>
Console.withOut(stream) {
Console.withErr(stream) {
compile(args: _*)
}
}
}
}
|