From 5ef6d9abb93105c5e0ddb40eda6bbed260e50549 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 1 Dec 2021 11:34:16 +0100 Subject: [PATCH] Fix type insert --- src/main/scala/hb/dhbw/InsertTypes.scala | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/scala/hb/dhbw/InsertTypes.scala b/src/main/scala/hb/dhbw/InsertTypes.scala index 41cef41..a6b72c3 100644 --- a/src/main/scala/hb/dhbw/InsertTypes.scala +++ b/src/main/scala/hb/dhbw/InsertTypes.scala @@ -81,18 +81,26 @@ object InsertTypes { private def getLinkedConstraints(linkedTypes: Set[Type], in: Set[Constraint]): Set[Constraint] ={ var typesWithoutBounds = linkedTypes in.flatMap(_ match { - case LessDot(GenericType(a), RefType(name, params)) => { - if(linkedTypes.contains(GenericType(a))){ - typesWithoutBounds = typesWithoutBounds - GenericType(a) + case LessDot(TypeVariable(a), RefType(name, params)) => { + if(linkedTypes.contains(TypeVariable(a))){ + typesWithoutBounds = typesWithoutBounds - TypeVariable(a) val genericsInParams = params.filter(_ match { - case GenericType(_) => true + case TypeVariable(_) => true case _ => false }).toSet - getLinkedConstraints(genericsInParams, in) +LessDot(GenericType(a), RefType(name, params)) + getLinkedConstraints(genericsInParams, in) + LessDot(GenericType(a), RefType(name, params)) }else{ Set() } } + case LessDot(TypeVariable(a), GenericType(g)) => if(linkedTypes.contains(TypeVariable(a))){ + typesWithoutBounds = typesWithoutBounds - TypeVariable(a) + Set(LessDot(GenericType(a), GenericType(g))) + }else Set() + case EqualsDot(TypeVariable(a), _) => if(linkedTypes.contains(TypeVariable(a))){ + typesWithoutBounds = typesWithoutBounds - TypeVariable(a) + Set() + }else Set() case _ => Set() }) ++ typesWithoutBounds.map(t => LessDot(t, RefType("Object", List()))) }