Skip to content

Commit 717a198

Browse files
committed
WIP non boxing
1 parent cd8fd76 commit 717a198

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package scala
22

3-
class RefinedScrutinee[+Scrutinee /*<: Singleton*/, +Result] private (val result: Option[Result]) extends AnyVal {
3+
final class RefinedScrutinee[+Scrutinee /*<: Singleton*/, +Result] private (val result: Any) extends AnyVal {
44
// Scrutinee in not a singleton to provide a better error message
55

66
/** There is no result */
7-
def isEmpty: Boolean = result.isEmpty
7+
def isEmpty: Boolean = result == RefinedScrutinee.NoResult
88

99
/** Get the result */
10-
def get: Result = result.get
10+
def get: Result = result.asInstanceOf[Result]
1111
}
1212

1313
object RefinedScrutinee {
14-
// TODO when bootstrapped: erase scrutinee as it is just an evidence for that existance of a term of type Scrutinee
15-
def matchOf[Scrutinee <: Singleton, Result](/*erased*/ scrutinee: Scrutinee)(result: Result): RefinedScrutinee[Scrutinee, Result] = new RefinedScrutinee(Some(result))
16-
def noMatch[Scrutinee <: Singleton, Result]: RefinedScrutinee[Scrutinee, Result] = new RefinedScrutinee(None)
14+
private[RefinedScrutinee] object NoResult
15+
16+
def matchOf[Scrutinee <: Singleton, Result](scrutinee: Scrutinee)(result: Result): RefinedScrutinee[Scrutinee, Result] = new RefinedScrutinee(result)
17+
def noMatch[Scrutinee <: Singleton, Result]: RefinedScrutinee[Scrutinee, Result] = new RefinedScrutinee(NoResult)
1718
}

0 commit comments

Comments
 (0)