-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #4323: allow narrowing of class type parameters in pattern match
- Loading branch information
1 parent
78ab82d
commit 05cf8f6
Showing
5 changed files
with
35 additions
and
2 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
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,9 @@ | ||
enum Expr[T] { | ||
case IExpr(value: Int) extends Expr[Int] | ||
case BExpr(value: Boolean) extends Expr[Boolean] | ||
|
||
def join(other: Expr[T]): Expr[T] = (this, other) match { | ||
case (IExpr(i1), IExpr(i2)) => IExpr(i1 + i2) | ||
case (BExpr(b1), BExpr(b2)) => BExpr(b1 & b2) | ||
} | ||
} |
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,13 @@ | ||
sealed trait Expr[T] { | ||
import Expr._ | ||
|
||
def join(other: Expr[T]): Expr[T] = (this, other) match { | ||
case (IExpr(i1), IExpr(i2)) => IExpr(i1 + i2) | ||
case (BExpr(b1), BExpr(b2)) => BExpr(b1 & b2) | ||
} | ||
} | ||
|
||
object Expr { | ||
case class IExpr(value: Int) extends Expr[Int] | ||
case class BExpr(value: Boolean) extends Expr[Boolean] | ||
} |
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,11 @@ | ||
sealed trait Expr[T] { outer => | ||
class Inner { | ||
def join(other: Expr[T]): Expr[T] = (outer, other) match { | ||
case (IExpr(i1), IExpr(i2)) => IExpr(i1 + i2) | ||
case (BExpr(b1), BExpr(b2)) => BExpr(b1 & b2) | ||
} | ||
} | ||
} | ||
|
||
case class IExpr(value: Int) extends Expr[Int] | ||
case class BExpr(value: Boolean) extends Expr[Boolean] |