Skip to content
Snippets Groups Projects
Commit 23469e1e authored by Emmanouil (Manos) Koukoutos's avatar Emmanouil (Manos) Koukoutos Committed by Etienne Kneuss
Browse files

Don't eliminate pattern matching if scrutinee:AbstractClassType

parent c89ede36
No related branches found
No related tags found
No related merge requests found
...@@ -113,7 +113,8 @@ class SimplifierWithPaths(sf: SolverFactory[Solver]) extends TransformerWithPC { ...@@ -113,7 +113,8 @@ class SimplifierWithPaths(sf: SolverFactory[Solver]) extends TransformerWithPC {
} }
newCases match { newCases match {
case List() => Error("Unreachable code").copiedFrom(e) case List() => Error("Unreachable code").copiedFrom(e)
case List(theCase) => case List(theCase) if !scrut.getType.isInstanceOf[AbstractClassType] =>
// Avoid AbstractClassType as it may lead to invalid field accesses
replaceFromIDs(mapForPattern(scrut, theCase.pattern), theCase.rhs) replaceFromIDs(mapForPattern(scrut, theCase.pattern), theCase.rhs)
case _ => MatchExpr(rs, newCases).copiedFrom(e) case _ => MatchExpr(rs, newCases).copiedFrom(e)
} }
......
...@@ -81,4 +81,13 @@ object Transform { ...@@ -81,4 +81,13 @@ object Transform {
a._1 a._1
} }
def input07(l : List[Int]) : Int = l match {
case Nil() if false => 42
case Cons(h,t) => h
}
def output07(l : List[Int]) : Int = l match {
case Cons(h,t) => h
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment