File: Test_2.scala

package info (click to toggle)
scala 2.11.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 62,924 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,135; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (42 lines) | stat: -rw-r--r-- 1,417 bytes parent folder | download | duplicates (4)
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
import scala.reflect.runtime.universe._

// Originally composed to accommodate pull request feedback, this test has
// uncovered a handful of bugs in FromJavaClassCompleter, namely:
// * SI-7071 non-public ctors get lost
// * SI-7072 inner classes are read incorrectly

// I'm leaving the incorrect results of FromJavaClassCompleters in the check
// file, so that we get notified when something changes there.

package object foo {
  def testAll(): Unit = {
    test(typeOf[foo.PackagePrivateJavaClass].typeSymbol)
    test(typeOf[foo.PackagePrivateJavaClass].typeSymbol.companion)
    test(typeOf[foo.JavaClass_1].typeSymbol)
    test(typeOf[foo.JavaClass_1].typeSymbol.companion)
  }

  def test(sym: Symbol): Unit = {
    printSymbolDetails(sym)
    if (sym.isClass || sym.isModule) {
      sym.info.decls.toList.sortBy(_.name.toString) foreach test
    }
  }

  def printSymbolDetails(sym: Symbol): Unit = {
    def stableSignature(sym: Symbol) = sym.info match {
      case ClassInfoType(_, _, _) => "ClassInfoType(...)"
      case tpe => tpe.toString
    }
    println("============")
    println(s"sym = $sym, signature = ${stableSignature(sym)}, owner = ${sym.owner}")
    println(s"isPrivate = ${sym.isPrivate}")
    println(s"isProtected = ${sym.isProtected}")
    println(s"isPublic = ${sym.isPublic}")
    println(s"privateWithin = ${sym.privateWithin}")
  }
}

object Test extends App {
  foo.testAll()
}