Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dealias val aliases to modules so they're =:=
This changes the definitely of =:= in the smallest possible way: if you have a singleton type that widens to a module, then widen to that module.
- Loading branch information
Showing
3 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// scalac: -Werror | ||
|
||
// this is remodeling of the scala package object and scala.collection.immutable.{ List, ::, Nil } | ||
// in order to: | ||
// * avoid the scala package, which is auto-imported | ||
// * avoid List, which is rewritten/fudged in the pattern matcher | ||
package skala.collect { | ||
sealed trait Xs[+A] | ||
final case class Cons[+A](head: A, tail: Xs[A]) extends Xs[A] | ||
final case object Done extends Xs[Nothing] | ||
object Xs | ||
} | ||
package object skala { | ||
type Cons[+A] = skala.collect.Cons[A] | ||
type Xs[+A] = skala.collect.Xs[A] | ||
val Cons = skala.collect.Cons | ||
val Done: skala.collect.Done.type = skala.collect.Done | ||
val Xs = skala.collect.Xs | ||
} | ||
|
||
import skala._ | ||
|
||
class Test { | ||
def test(xs: Xs[Int]): Boolean = xs match { | ||
case Cons(_, _) => true | ||
case _: Done.type => false | ||
//case _: skala.collect.Done.type => false // done this way it already works | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters