summaryrefslogtreecommitdiff
path: root/test/files/run/t10171/Test.scala
blob: 37a2cfc67f929ab83528c48eab3b528a6e8a8a91 (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
57
58
59
import scala.tools.partest._
import java.io.File

object Test extends StoreReporterDirectTest {
  def code = ???

  def compileCode(code: String) = {
    val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
    compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code)
  }

  def library = """
package a {
  package b {
    class C { class D }
  }
}
package z {
  class Base {
    type S = String
    def foo(s: S): a.b.C#D = null
  }
  class Sub extends Base {
    def sub = "sub"
  }
}
  """

  def client = """
    class Client { new z.Sub().sub }
  """

  def deleteClass(s: String) = {
    val f = new File(testOutput.path, s + ".class")
    assert(f.exists)
    f.delete()
  }

  def deletePackage(s: String) = {
    val f = new File(testOutput.path, s)
    assert(f.exists)
    f.delete()
  }

  def assertNoErrors(): Unit = {
    assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n"))
    storeReporter.reset()
  }
  def show(): Unit = {
    compileCode(library)
    assertNoErrors()
    deleteClass("a/b/C$D")
    deleteClass("a/b/C")
    deletePackage("a/b")
    compileCode(client)
    assertNoErrors()
  }
}