File: t1786-counter.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 (38 lines) | stat: -rw-r--r-- 1,888 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
trait ShapeLevel

object Fail {
  abstract class ProductNodeShape[Level <: ShapeLevel, C, M <: C, U <: C, P <: C] extends Shape[Level, M, U, P] {
    def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _]
  }

  abstract class Shape[Level <: ShapeLevel, -Mixed_, Unpacked_, Packed_]

  final class TupleShape[Level <: ShapeLevel, M <: Product, U <: Product, P <: Product](val shapes: Shape[_, _, _, _]*) extends ProductNodeShape[Level, Product, M, U, P] {
    def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _] = ???
  }

  trait ShapeLevel
}

object Ok {
  abstract class Shape[Level <: ShapeLevel, -Mixed_, Unpacked_, Packed_]

  abstract class ProductNodeShape[Level <: ShapeLevel, C, M <: C, U <: C, P <: C] extends Shape[Level, M, U, P] {
    def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _]
  }

  final class TupleShape[Level <: ShapeLevel, M <: Product, U <: Product, P <: Product](val shapes: Shape[_, _, _, _]*) extends ProductNodeShape[Level, Product, M, U, P] {
    def copy(shapes: Seq[Shape[_, _, _, _]]): Shape[Level, _, _, _] = ???
  }
}

// This is why we reverted the fix for SI-1786 -- see SI-6169 for a potential alternative that could be extended to cover this.
// both objects type check on 2.10.3, but only Ok was accepted by 2.11 after the original fix to SI-1786.
// Fail results in:
/*
t1786-counter.scala:10: error: class TupleShape needs to be abstract, since method copy in class ProductNodeShape of type (shapes: Seq[Fail.Shape[_, _, _, _]])Fail.Shape[Level, _, _, _] is not defined
(Note that Seq[Fail.Shape[_, _, _, _]] does not match Seq[Fail.Shape[_ <: Fail.ShapeLevel, _, _, _]]: their type parameters differ)
  final class TupleShape[Level <: ShapeLevel, M <: Product, U <: Product, P <: Product](val shapes: Shape[_, _, _, _]*) extends ProductNodeShape[Level, Product, M, U, P] {
              ^
one error found
*/