aboutsummaryrefslogtreecommitdiff
path: root/tests/disabled/scalac-dependent/structural.scala
blob: 0f18f45791842933423bee49b371860a8ccfbe15 (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
case class Record(elems: (String, Any)*) extends Selectable {
  def selectDynamic(name: String): Any = elems.find(_._1 == name).get._2
}

object Test {
  import scala.reflect.Selectable.reflectiveSelectable

  def f(closeable: { def close(): Unit }) =
    closeable.close()

  type RN = Record { val name: String; val age: Int }

  def g(r: RN) = r.name

  val rr: RN = Record("name" -> "Bob", "age" -> 42).asInstanceOf[RN]

  def main(args: Array[String]): Unit = {
    f(new java.io.PrintStream("foo"))
    assert(g(rr) == "Bob")

    val s: { def concat(s: String): String } = "abc"
    assert(s.concat("def") == "abcdef")
  }
}