Skip to content

Commit

Permalink
Adapt tests to restricted meaning of GADTs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
odersky committed Oct 15, 2018
1 parent 716b3a0 commit 207c380
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/pos/opaque-immutable-array.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ object ia {

object IArray {
inline def initialize[A](body: => Array[A]): IArray[A] = body
inline def size[A](ia: IArray[A]): Int = ia.length
inline def get[A](ia: IArray[A], i: Int): A = ia(i)
inline def size[A](ia: IArray[A]): Int = (ia: Array[A]).length
inline def get[A](ia: IArray[A], i: Int): A = (ia: Array[A])(i)

// return a sorted copy of the array
def sorted[A <: AnyRef : math.Ordering](ia: IArray[A]): IArray[A] = {
val arr = Arrays.copyOf(ia, ia.length)
val arr = Arrays.copyOf(ia, (ia: Array[A]).length)
scala.util.Sorting.quickSort(arr)
arr
}
Expand Down
6 changes: 3 additions & 3 deletions tests/pos/opaque-propability.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ object prob {
implicitly[Ordering[Double]]

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

def isImpossible: Boolean = p1 == Never
def isCertain: Boolean = p1 == Certain
Expand Down

0 comments on commit 207c380

Please sign in to comment.