Skip to content
Snippets Groups Projects
Commit fe5b91db authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

CodeGen tests for overrides

parent 8a049143
Branches
Tags
No related merge requests found
......@@ -521,8 +521,7 @@ trait CodeGeneration {
}
}
// No dynamic dispatching/overriding in Leon,
// so no need to take care of own vs. "super" methods
// No interfaces in Leon, so no need to use InvokeInterface
ch << InvokeVirtual(className, methodName, sig)
(tfd.fd.returnType, tfd.returnType) match {
......
......@@ -121,7 +121,9 @@ class CodeGenSuite extends test.LeonTestSuite {
// This one loops!
("lazyLoops" , Error(Untyped, "Looping") ),
("Lazier" , IntLiteral(1 + 2 + 3) ),
("SetToList", BooleanLiteral(true) )
("SetToList", BooleanLiteral(true) ),
("Overrides1", Tuple(Seq(BooleanLiteral(false), BooleanLiteral(true))) ),
("Overrides2", Tuple(Seq(BooleanLiteral(false), BooleanLiteral(true))) )
)
......@@ -362,6 +364,28 @@ class CodeGenSuite extends test.LeonTestSuite {
s == s2
}
}
object Overrides1 {
abstract class A {
def x = true
}
case class B() extends A {
override def x = false
}
case class C() extends A
def test = (B().x, C().x)
}
object Overrides2 {
abstract class A {
val x = true
}
case class B() extends A {
override val x = false
}
case class C() extends A
def test = (B().x, C().x)
}
"""
runTests()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment