From 4525e3392b42b47147479087d961d328c3b717bb Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 4 Feb 2014 22:29:52 -0800 Subject: SI-6169 Refine java wildcard bounds using corresponding tparam Also fixes part of SI-8197. Necessary complement to SI-1786 (#2518), because we now infer tighter bounds for RHSs to conform to. When opening an existential, Java puts constraints in the typing environment that are derived from the bounds on the type parameters of the existentially quantified type, so let's do the same for existentials over java-defined classes in skolemizeExistential... Example from test case: ``` public class Exist { // java helpfully re-interprets Exist as Exist public Exist foo() { throw new RuntimeException(); } } ``` In Scala syntax, given a java-defined `class C[T <: String]`, the existential type `C[_]` is improved to `C[_ <: String]` before skolemization, which models what Java does (track the bounds as type constraints in the typing environment) (Also tried doing this once during class file parsing or when creating the existential type, but that causes cyclic errors because it happens too early.) --- test/files/pos/t6169/ExistIndir.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/files/pos/t6169/ExistIndir.java (limited to 'test/files/pos/t6169/ExistIndir.java') diff --git a/test/files/pos/t6169/ExistIndir.java b/test/files/pos/t6169/ExistIndir.java new file mode 100644 index 0000000000..e66d1698c4 --- /dev/null +++ b/test/files/pos/t6169/ExistIndir.java @@ -0,0 +1,4 @@ +public class ExistIndir { + // java helpfully re-interprets ExistIndir as ExistIndir + public ExistIndir foo() { throw new RuntimeException(); } +} -- cgit v1.2.3