File: t7507.scala

package info (click to toggle)
scala 2.11.12-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 62,776 kB
  • sloc: java: 13,415; xml: 3,252; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (35 lines) | stat: -rw-r--r-- 685 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
trait Cake extends Slice

// Minimization
trait Slice { self: Cake =>    // must have self type that extends `Slice`
  private[this] val bippy = () // must be private[this]
  locally(bippy)
  class C1 {
    locally(bippy)
    locally(self.bippy)
  }
}

// Originally reported bug:
trait Cake1 extends Slice1
trait Slice1 { self: Cake1 =>
  import java.lang.String // any import will do!
  val Tuple2(x, y) = ((1, 2))
}


// Nesting
trait Cake3 extends Outer.Slice3

// Minimization
object Outer {
  private[this] val bippy = ()
  trait Slice3 { self: Cake3 =>
    locally(bippy)
  }
}

object Test extends App {
  val s1 = new Cake1 {}
  assert((s1.x, s1.y) == (1, 2), (s1.x, s1.y))
}