From 013abb7e5a3fc8a6f7a2ca79eb9e5e832f0fdbe5 Mon Sep 17 00:00:00 2001
From: Manos Koukoutos <emmanouil.koukoutos@epfl.ch>
Date: Fri, 4 Sep 2015 16:21:39 +0200
Subject: [PATCH] Validate tparams for abstract classes too

---
 .../frontends/scalac/CodeExtraction.scala     | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/main/scala/leon/frontends/scalac/CodeExtraction.scala b/src/main/scala/leon/frontends/scalac/CodeExtraction.scala
index 0a6633aa4..a5d0deb5d 100644
--- a/src/main/scala/leon/frontends/scalac/CodeExtraction.scala
+++ b/src/main/scala/leon/frontends/scalac/CodeExtraction.scala
@@ -526,24 +526,24 @@ trait CodeExtraction extends ASTExtractors {
 
         ccd.setFields(fields)
 
-        // Validates type parameters
-        parent foreach { pct =>
-          if(pct.classDef.tparams.size == tparams.size) {
-            val pcd = pct.classDef
-            val ptps = pcd.tparams.map(_.tp)
+        ccd
+      }
 
-            val targetType = AbstractClassType(pcd, ptps)
-            val fromChild = CaseClassType(ccd, ptps).parent.get
+      // Validates type parameters
+      parent foreach { pct =>
+        if(pct.classDef.tparams.size == tparams.size) {
+          val pcd = pct.classDef
+          val ptps = pcd.tparams.map(_.tp)
 
-            if (fromChild != targetType) {
-              outOfSubsetError(sym.pos, "Child type should form a simple bijection with parent class type (e.g. C[T1,T2] extends P[T1,T2])")
-            }
-          } else {
-            outOfSubsetError(sym.pos, "Child classes should have the same number of type parameters as their parent")
+          val targetType = AbstractClassType(pcd, ptps)
+          val fromChild = cd.typed(ptps).parent.get
+
+          if (fromChild != targetType) {
+            outOfSubsetError(sym.pos, "Child type should form a simple bijection with parent class type (e.g. C[T1,T2] extends P[T1,T2])")
           }
+        } else {
+          outOfSubsetError(sym.pos, "Child classes should have the same number of type parameters as their parent")
         }
-
-        ccd
       }
 
       //println(s"Body of $sym")
-- 
GitLab