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

Revert "Fix treatment of 'this' in MethodLifting"

This reverts commit c4bf3e88.
parent 1a5c40e7
No related branches found
No related tags found
No related merge requests found
...@@ -79,8 +79,8 @@ object MethodLifting extends TransformationPhase { ...@@ -79,8 +79,8 @@ object MethodLifting extends TransformationPhase {
val at = acd.typed val at = acd.typed
val binder = FreshIdentifier(acd.id.name.toLowerCase, at, true) val binder = FreshIdentifier(acd.id.name.toLowerCase, at, true)
def subst(e: Expr): Expr = e match { def subst(e: Expr): Expr = e match {
case This(ct) => case This(`at`) =>
asInstOf(Variable(binder), ct) Variable(binder)
case e => case e =>
e e
} }
...@@ -158,19 +158,14 @@ object MethodLifting extends TransformationPhase { ...@@ -158,19 +158,14 @@ object MethodLifting extends TransformationPhase {
nfd.addFlag(IsMethod(cd)) nfd.addFlag(IsMethod(cd))
if (cd.knownDescendants.forall( cd => (cd.methods ++ cd.fields).forall(_.id != fd.id))) { if (cd.knownDescendants.forall( cd => (cd.methods ++ cd.fields).forall(_.id != fd.id))) {
// Don't need to compose methods
val paramsMap = fd.params.zip(fdParams).map{case (x,y) => (x.id, y.id)}.toMap val paramsMap = fd.params.zip(fdParams).map{case (x,y) => (x.id, y.id)}.toMap
def thisToReceiver(e: Expr): Option[Expr] = e match { // Don't need to compose methods
case th@This(ct) => //if ct.classDef == cd => nfd.fullBody = postMap {
Some(asInstOf(receiver.toVariable, ct).setPos(th)) case th@This(ct) if ct.classDef == cd =>
Some(receiver.toVariable.setPos(th))
case _ => case _ =>
None None
} }(instantiateType(nfd.fullBody, tparamsMap, paramsMap))
nfd.fullBody = instantiateType(
postMap(thisToReceiver)(nfd.fullBody),
tparamsMap,
paramsMap
)
} else { } else {
// We need to compose methods of subclasses // We need to compose methods of subclasses
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment