File: t8852a.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 (37 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (3)
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
import scala.tools.partest._

// Test that static methods in Java interfaces (new in Java 8)
// are callable from jointly compiler Scala code.
object Test extends CompilerTest {
  import global._


  override def extraSettings: String = super.extraSettings + " -target:jvm-1.8"

  override lazy val units: List[CompilationUnit] = {
    // This test itself does not depend on JDK8.
    javaCompilationUnits(global)(staticMethodInInterface) ++
    compilationUnits(global)(scalaClient)
  }

  private def staticMethodInInterface = """
public interface Interface {
  public static int staticMethod() {
    return 42;
  }
}

  """

  private def scalaClient = """
object Test {
  val x: Int = Interface.staticMethod()
}

class C extends Interface // expect no errors about unimplemented members.

  """

  // We're only checking we can compile it.
  def check(source: String, unit: global.CompilationUnit): Unit = ()
}