From 341875c84318900f9857f0c030e27571f5fa30a8 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Sat, 11 Dec 2021 23:21:08 +0100 Subject: [PATCH] Fix insertTypes --- src/main/scala/hb/dhbw/InsertTypes.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/scala/hb/dhbw/InsertTypes.scala b/src/main/scala/hb/dhbw/InsertTypes.scala index de6a50f..8026e90 100644 --- a/src/main/scala/hb/dhbw/InsertTypes.scala +++ b/src/main/scala/hb/dhbw/InsertTypes.scala @@ -97,9 +97,13 @@ object InsertTypes { typesWithoutBounds = typesWithoutBounds - TypeVariable(a) Set(LessDot(GenericType(a), GenericType(g))) }else Set() - case EqualsDot(TypeVariable(a), RefType(_,_)) => if(linkedTypes.contains(TypeVariable(a))){ + case EqualsDot(TypeVariable(a), RefType(_,params)) => if(linkedTypes.contains(TypeVariable(a))){ typesWithoutBounds = typesWithoutBounds - TypeVariable(a) - Set() + val genericsInParams = params.filter(_ match { + case TypeVariable(_) => true + case _ => false + }).toSet + getLinkedConstraints(genericsInParams, in) }else Set() case EqualsDot(TypeVariable(a), TypeVariable(b)) => if(linkedTypes.contains(TypeVariable(a))){ typesWithoutBounds = typesWithoutBounds - TypeVariable(a) @@ -129,12 +133,12 @@ object InsertTypes { } val genericRetType = substType(into.retType) - val genericParams = into.params.map(p => (substType(p._1), p._2)) + val substitutedParams = into.params.map(p => (substType(p._1), p._2)) val tvsUsedInMethod = (Set(into.retType) ++ into.params.map(_._1)).flatMap(getAllTVs(_)) val constraintsForMethod = getLinkedConstraints(tvsUsedInMethod, constraints) val mCons = (into.genericParams ++ constraintsForMethod).map(replaceTypeVarWithGeneric(_)) - Method(mCons, genericRetType, into.name, genericParams, into.retExpr) + Method(mCons, genericRetType, into.name, substitutedParams, into.retExpr) } private def replaceTypeVarWithGeneric(in: Constraint): Constraint= in match {