From 5c62191f3bf811dcd10cf52aa9100373366a93b0 Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Tue, 4 Jul 2023 12:17:14 +0200 Subject: [PATCH] Consider constructors when creating class generics --- resources/bytecode/javFiles/PairNoGenerics.jav | 0 .../target/generate/GenerateGenerics.java | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 resources/bytecode/javFiles/PairNoGenerics.jav diff --git a/resources/bytecode/javFiles/PairNoGenerics.jav b/resources/bytecode/javFiles/PairNoGenerics.jav new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java b/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java index e966d29d..2f437d6e 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.target.generate; +import com.google.common.collect.Streams; import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.Constructor; @@ -18,6 +19,8 @@ import de.dhbwstuttgart.util.Pair; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; public abstract class GenerateGenerics { @@ -145,6 +148,7 @@ public abstract class GenerateGenerics { } else if (constraint instanceof PairTPHEqualTPH p) { equality.put(p.getLeft(), p.getRight()); } else if (constraint instanceof PairTPHequalRefTypeOrWildcardType p) { + System.out.println(p.left + " = " + p.right); concreteTypes.put(new TPH(p.left), p.right); } } @@ -761,14 +765,14 @@ public abstract class GenerateGenerics { oldFamily.clear(); oldFamily.putAll(familyOfMethods); familyOfMethods.clear(); - for (var method : classOrInterface.getMethods()) { + Stream.concat(classOrInterface.getMethods().stream(), classOrInterface.getConstructors().stream()).forEach(method -> { family(classOrInterface, method); - } + }); } while(!oldFamily.equals(familyOfMethods)); - for (var method : classOrInterface.getMethods()) { + Stream.concat(classOrInterface.getMethods().stream(), classOrInterface.getConstructors().stream()).forEach(method -> { generics(classOrInterface, method); - } + }); } private void findChain(Set referenced, Set input, Set output, TPH start, TPH end, Set chain) {