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

Validate tparams for abstract classes too

parent 8ef26e39
No related branches found
No related tags found
No related merge requests found
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment