Skip to content

Commit 207c380

Browse files
committed
Adapt tests to restricted meaning of GADTs
In the new implementation, a companion object of an opaque type opaque type T = A only knows that T <: A and that A <: T. By itself that does not propagate some informations from `A` to `T`. For instance the members of A are now not the members of T.
1 parent 716b3a0 commit 207c380

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/pos/opaque-immutable-array.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ object ia {
66

77
object IArray {
88
inline def initialize[A](body: => Array[A]): IArray[A] = body
9-
inline def size[A](ia: IArray[A]): Int = ia.length
10-
inline def get[A](ia: IArray[A], i: Int): A = ia(i)
9+
inline def size[A](ia: IArray[A]): Int = (ia: Array[A]).length
10+
inline def get[A](ia: IArray[A], i: Int): A = (ia: Array[A])(i)
1111

1212
// return a sorted copy of the array
1313
def sorted[A <: AnyRef : math.Ordering](ia: IArray[A]): IArray[A] = {
14-
val arr = Arrays.copyOf(ia, ia.length)
14+
val arr = Arrays.copyOf(ia, (ia: Array[A]).length)
1515
scala.util.Sorting.quickSort(arr)
1616
arr
1717
}

tests/pos/opaque-propability.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ object prob {
2020
implicitly[Ordering[Double]]
2121

2222
implicit class ProbabilityOps(p1: Probability) extends AnyVal {
23-
def unary_~ : Probability = Certain - p1
24-
def &(p2: Probability): Probability = p1 * p2
25-
def |(p2: Probability): Probability = p1 + p2 - (p1 * p2)
23+
def unary_~ : Probability = asDouble(Certain) - p1
24+
def &(p2: Probability): Probability = asDouble(p1) * p2
25+
def |(p2: Probability): Probability = asDouble(p1) + p2 - (asDouble(p1) * p2)
2626

2727
def isImpossible: Boolean = p1 == Never
2828
def isCertain: Boolean = p1 == Certain

0 commit comments

Comments
 (0)