From 1c31b6d7691ffc8b8f42e7760401988e884a72b2 Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Tue, 7 Mar 2023 08:51:31 +0100 Subject: [PATCH] new file: ../../AllgemeinTest/Pair.jav new file: ../../AllgemeinTest/UseWildcardPair.jav modified: ../../../src/test/java/AllgemeinTest.java --- resources/AllgemeinTest/Pair.jav | 26 +++++++++++++++++++++ resources/AllgemeinTest/UseWildcardPair.jav | 12 ++++++++++ src/test/java/AllgemeinTest.java | 4 +++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 resources/AllgemeinTest/Pair.jav create mode 100644 resources/AllgemeinTest/UseWildcardPair.jav diff --git a/resources/AllgemeinTest/Pair.jav b/resources/AllgemeinTest/Pair.jav new file mode 100644 index 000000000..fc2de47cc --- /dev/null +++ b/resources/AllgemeinTest/Pair.jav @@ -0,0 +1,26 @@ +import java.util.Vector; +import java.lang.Boolean; + +class Pair { + U a; + T b; + + make(x) { + var ret = new Pair<>(); + ret.a = x.elementAt(0); + ret.b = x.elementAt(1); + return ret; + } + /* + compare(p) { + + return p.a = p.b; + } + + void m(Pair p, List b) + { + //this.compare(p); //1, type incorrect + this.compare(this.make(b)); //2, OK + } +*/ +} \ No newline at end of file diff --git a/resources/AllgemeinTest/UseWildcardPair.jav b/resources/AllgemeinTest/UseWildcardPair.jav new file mode 100644 index 000000000..42c648167 --- /dev/null +++ b/resources/AllgemeinTest/UseWildcardPair.jav @@ -0,0 +1,12 @@ +import java.util.Vector; +import java.lang.Boolean; + +class UseWildcardPair{ + + void m(Pair p, Vector b) + { + p.compare(p); //1, type incorrect + p.compare(p.make(b)); //2, OK + } + +} \ No newline at end of file diff --git a/src/test/java/AllgemeinTest.java b/src/test/java/AllgemeinTest.java index 34991a6a5..ad389c7a0 100644 --- a/src/test/java/AllgemeinTest.java +++ b/src/test/java/AllgemeinTest.java @@ -51,7 +51,9 @@ public class AllgemeinTest { //String className = "VectorConstAdd"; //String className = "VectorNotObject"; //String className = "WildcardCaptureConversionTest"; - String className = "CaptureConversion"; + //String className = "CaptureConversion"; + String className = "Pair"; + //String className = "UseWildcardPair"; //PL 2019-10-24: genutzt fuer unterschiedliche Tests path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav"; //path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";