This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: more conversion fixes
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 31 Oct 2005 17:11:32 -0700
- Subject: [gcjx] Patch: FYI: more conversion fixes
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This changes widening reference conversion to apply capture
conversion. It also fixes wildcards so that they correctly apply type
maps. It fixes return type substitutability checking to correct apply
unchecked conversion. And, it fixes a bad prototype in
conversions.hh.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/wildcard.cc (apply_type_map): New method.
* model/wildcard.hh (model_wildcard::apply_type_map): Declare.
* model/method.cc (return_type_substitutable_p): Correctly apply
unchecked conversion.
* conversions.cc (widen_instantiation): Use capture_conversion.
* conversions.hh (capture_conversion): Fixed.
Index: conversions.cc
===================================================================
--- conversions.cc (revision 105957)
+++ conversions.cc (working copy)
@@ -197,9 +197,10 @@
return false;
}
- // Now we check 'contains' of each type argument. FIXME: we should
- // perform capture conversion or equivalent on 'from'.
- model_class_instance *from_i = assert_cast<model_class_instance *> (from);
+ // Now we check 'contains' of each type argument.
+ model_class_instance *from_i
+ = capture_conversion (from /* FIXME */,
+ assert_cast<model_class_instance *> (from));
model_class_instance *to_i = assert_cast<model_class_instance *> (to);
std::list<model_class *> from_args, to_args;
from_i->get_type_map (from_args);
Index: model/wildcard.hh
===================================================================
--- model/wildcard.hh (revision 106298)
+++ model/wildcard.hh (working copy)
@@ -83,6 +83,8 @@
return bool (bound);
}
+ model_class *apply_type_map (model_element *, const model_type_map &);
+
model_type *erasure ();
bool assignable_from_p (model_type *);
Index: model/method.cc
===================================================================
--- model/method.cc (revision 105944)
+++ model/method.cc (working copy)
@@ -443,10 +443,11 @@
{
if (base->assignable_from_p (derived))
return true;
- // Unchecked conversion here means that the erasure of derived
- // is a subtype of base.
+ // Maybe the return type of DERIVED can be converted to the
+ // return type of BASE by unchecked conversion. For this to
+ // happen, DERIVED must be a raw type and we must look at the
+ // erasure of BASE.
// FIXME: must emit unchecked warning.
- return base->assignable_from_p (derived->erasure ());
}
// Otherwise, derived must be a subtype of the erasure of base.
Index: model/wildcard.cc
===================================================================
--- model/wildcard.cc (revision 106298)
+++ model/wildcard.cc (working copy)
@@ -86,6 +86,23 @@
}
}
+model_class *
+model_wildcard::apply_type_map (model_element *request,
+ const model_type_map &typemap)
+{
+ if (! bound)
+ return this;
+ model_class *bound_class = assert_cast<model_class *> (bound->type ());
+ model_class *applied = bound_class->apply_type_map (request, typemap);
+ if (bound_class == applied)
+ return this;
+ // FIXME: ownership.
+ // FIXME: location from request? Or from 'this'?
+ model_wildcard *result = new model_wildcard (request->get_location (),
+ applied, is_super);
+ return result;
+}
+
model_type *
model_wildcard::erasure ()
{
Index: conversions.hh
===================================================================
--- conversions.hh (revision 105957)
+++ conversions.hh (working copy)
@@ -65,8 +65,10 @@
/// This implements capture conversion as defined in the JLS.
/// Essentially it replaces wildcards in a parameterization with new
-/// type variables.
-model_class_instance *capture_conversion (model_class_instance *);
+/// type variables. The first argument is a request argument; it is
+/// used for its location only.
+model_class_instance *capture_conversion (model_element *,
+ model_class_instance *);
/// Return the wrapper type for a given primitive type. This also
/// works for `void'. Only primitive types and void can be passed as