This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: inference fixlets
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 29 Nov 2005 16:28:59 -0700
- Subject: [gcjx] Patch: FYI: inference fixlets
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a couple minor things in the type inference code. If there
is only one constraint we simplify the LUB computation. (Actually it
is unclear whether this is really correct. But it solves a test case
and I couldn't really think of a different way to do it.)
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* unify.cc (unifier::imply): Added constraint.
(unifier::consider_lubs): Only look at '>>' constraints.
* model/classinst.cc (contains_p): Handle raw types.
* model/raw.hh (model_raw_class::raw_p): New method.
* model/class.hh (model_class::raw_p): New method.
Index: model/classinst.cc
===================================================================
--- model/classinst.cc (revision 107604)
+++ model/classinst.cc (working copy)
@@ -171,6 +171,13 @@
bool
model_class_instance::contains_p (model_class *oc)
{
+ if (oc->raw_p ())
+ {
+ model_raw_class *raw = assert_cast<model_raw_class *> (oc);
+ // FIXME: if true, isn't this is an unchecked conversion?
+ return parent == raw->get_parent ();
+ }
+
model_class_instance *other = dynamic_cast<model_class_instance *> (oc);
if (! other || parent != other->get_parent ())
return false;
Index: model/raw.hh
===================================================================
--- model/raw.hh (revision 107604)
+++ model/raw.hh (working copy)
@@ -51,6 +51,11 @@
return this;
}
+ bool raw_p () const
+ {
+ return true;
+ }
+
model_type *erasure ()
{
return this;
Index: model/class.hh
===================================================================
--- model/class.hh (revision 107604)
+++ model/class.hh (working copy)
@@ -493,6 +493,12 @@
return false;
}
+ // Return true if this class is a raw type.
+ virtual bool raw_p () const
+ {
+ return false;
+ }
+
// Return true if this class was defined in a static context.
bool static_context_p () const
{
Index: unify.cc
===================================================================
--- unify.cc (revision 107604)
+++ unify.cc (working copy)
@@ -76,6 +76,7 @@
void imply (constraint_type type, model_class *formal, model_class *actual)
{
+ assert (formal_type_variable_p (formal));
constraints[type].push_back (std::make_pair (formal, actual));
}
@@ -301,6 +302,9 @@
// This name comes from the JLS.
model_class *compute_lub (const std::set<model_class *> &constraints)
{
+ if (constraints.size () == 1)
+ return *(constraints.begin ());
+
inv_map_type inv_map;
compute_inv (constraints, inv_map);
@@ -535,7 +539,6 @@
else
{
std::set<model_class *> constraints;
- update_constraint_set (LESS_THAN, *i, constraints);
update_constraint_set (GREATER_THAN, *i, constraints);
model_class *lub = compute_lub (constraints);
if (lub == NULL)