aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/compExceptions/structural.scala
blob: 1d25062909f327dd12a9256f37f498996865e3c4 (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
60
61
62
63
64
65
66
67
68
69
70
package p1 {

object test123 {
  type A = { def a: Int }
  def f(a: A): A = a
}

object structural2 {
  type A = { def a: Int }

  type B = {
    def b: Int
  }

  type AB = A & B

  def f(ab: AB): AB = ab

  f(new {
    def a = 43
    def b = 42
  })
}
}

package p2 {
object RClose {
  type ReflectCloseable = { def close(): Unit }
  def withReflectCloseable[T <: ReflectCloseable, R](s: T)(action: T => R): R =
    try {
      action(s)
    } finally {
      s.close()
    }
}
}

package p3 {
object Test {
  def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t)

  def main(args: Array[String]): Unit = {
    idMap(Some(5))
    idMap(Responder.constant(5))
  }
}
}
package p4 {

trait A { self: Any { def p: Any } =>
  def f(b: => Unit): Unit = {}
  f { p } // error: cannot access member 'p' from structural type
}
}

package p5 {
// t2810
object Test {
  val closeable1: { def close(): Unit } = new scala.io.Source { val iter: Iterator[Char] = "".iterator }
  val closeable2: { def close(): Unit } = new java.io.Closeable { def close() = {} }
}
}

package p6 {

  class Refinements {
    val y: C { val x: T; type T }  // was adeprecated warning: illegal forward reference in refinement; now illegal
  }

}