diff options
author | Tom Tromey <tromey@redhat.com> | 2005-11-07 21:46:52 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2005-11-07 21:46:52 +0000 |
commit | 1387acbac90cc53e9ebd509b9d3c4844d15e635d (patch) | |
tree | 6710919f693f6a1234ef507d2a973138273ecf38 | |
parent | 6211ca9d9da126491cfb658722bbb7985d91e5ca (diff) |
* access.cc (unwrap_raw_class): New function.
(accessible_p): Use it.
(trampoline_required_p): Likewise.
* model/fwdtype.cc (maybe_get_erasure): Removed.
(resolve): Don't take erasure.
* name.cc (maybe_get_erasure): New function.
(classify_type_name): Use it.
* conversions.cc (widen_instantiation): Don't do capture
conversion.
* model/wildcard.cc (contains_p): Handle case where other
wildcard does not have a bound.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcjx-branch@106616 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcjx/ChangeLog | 14 | ||||
-rw-r--r-- | gcjx/access.cc | 35 | ||||
-rw-r--r-- | gcjx/conversions.cc | 8 | ||||
-rw-r--r-- | gcjx/model/fwdtype.cc | 14 | ||||
-rw-r--r-- | gcjx/model/wildcard.cc | 5 | ||||
-rw-r--r-- | gcjx/name.cc | 17 |
6 files changed, 65 insertions, 28 deletions
diff --git a/gcjx/ChangeLog b/gcjx/ChangeLog index f5917156bf3..95ad3df2ab1 100644 --- a/gcjx/ChangeLog +++ b/gcjx/ChangeLog @@ -1,5 +1,19 @@ 2005-11-07 Tom Tromey <tromey@redhat.com> + * access.cc (unwrap_raw_class): New function. + (accessible_p): Use it. + (trampoline_required_p): Likewise. + * model/fwdtype.cc (maybe_get_erasure): Removed. + (resolve): Don't take erasure. + * name.cc (maybe_get_erasure): New function. + (classify_type_name): Use it. + * conversions.cc (widen_instantiation): Don't do capture + conversion. + * model/wildcard.cc (contains_p): Handle case where other + wildcard does not have a bound. + +2005-11-07 Tom Tromey <tromey@redhat.com> + * model/parameters.hh (model_instance_cache::erasure): New field. (model_instance_cache::find_erased_instance): New method. (model_instance_cache::add_erased_instance): Likewise. diff --git a/gcjx/access.cc b/gcjx/access.cc index 729578cf7f4..8579ee1b4c6 100644 --- a/gcjx/access.cc +++ b/gcjx/access.cc @@ -1,6 +1,6 @@ // Access control. -// Copyright (C) 2004 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005 Free Software Foundation, Inc. // // This file is part of GCC. // @@ -21,6 +21,21 @@ #include "typedefs.hh" +static model_class * +unwrap_raw_class (model_class *k) +{ + model_raw_class *raw = dynamic_cast<model_raw_class *> (k); + if (raw) + k = raw->get_parent (); + else + { + model_class_instance *classi = dynamic_cast<model_class_instance *> (k); + if (classi) + k = classi->get_parent (); + } + return k; +} + bool accessible_p (model_type *t, IContext *request) { @@ -30,7 +45,7 @@ accessible_p (model_type *t, IContext *request) if (t->primitive_p ()) return true; - model_class *klass = assert_cast<model_class *> (t); + model_class *klass = unwrap_raw_class (assert_cast<model_class *> (t)); if (! klass->member_p ()) { @@ -59,7 +74,8 @@ accessible_p (model_type *t, IContext *request) // the declarer. Note the initial cast will return NULL when // REQUEST is a package. model_class *declarer = klass->get_declaring_class (); - for (model_class *prot = dynamic_cast<model_class *> (request); + for (model_class *prot + = unwrap_raw_class (dynamic_cast<model_class *> (request)); prot; prot = prot->get_lexically_enclosing_class ()) { @@ -73,9 +89,11 @@ accessible_p (model_type *t, IContext *request) // Access is permitted only within the body of the top-level // class enclosing the declaration. klass = klass->get_top_level_class (); - while (request != NULL && request != klass) - request = request->get_lexically_enclosing_class (); - return request == klass; + model_class *req_class + = unwrap_raw_class (dynamic_cast<model_class *> (request)); + while (req_class != NULL && req_class != klass) + req_class = req_class->get_lexically_enclosing_class (); + return req_class == klass; } // Default access, but also one case of protected access. @@ -111,8 +129,8 @@ accessible_p (IMember *target, IContext *request, model_class *qualifier, } if (dynamic_cast<model_class *> (request) != NULL) - request = assert_cast<model_class *> (assert_cast<model_class *> (request)->erasure ()); - declarer = assert_cast<model_class *> (declarer->erasure ()); + request = unwrap_raw_class (assert_cast<model_class *> (request)); + declarer = unwrap_raw_class (declarer); // Make sure we can access the declaring class. if (! accessible_p (declarer, request)) @@ -179,6 +197,7 @@ trampoline_required_p (const IMember *target, model_class *request, model_class **result) { assert (result); + request = unwrap_raw_class (request); // Access to the same class is fine. model_class *tclass = target->get_declaring_class (); diff --git a/gcjx/conversions.cc b/gcjx/conversions.cc index b3da264e91b..f64b97de48b 100644 --- a/gcjx/conversions.cc +++ b/gcjx/conversions.cc @@ -199,9 +199,11 @@ widen_instantiation (model_class *to, model_class *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 *from_i = assert_cast<model_class_instance *> (from); + // The spec says to do capture conversion on 'from_i' here, but then + // it does not define the 'contains' operation on type variables. + // This causes us to reject valid assignments. Instead we just keep + // the un-captured parameterization, which does the right thing. 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); diff --git a/gcjx/model/fwdtype.cc b/gcjx/model/fwdtype.cc index a79eaace62f..4e6589cd89c 100644 --- a/gcjx/model/fwdtype.cc +++ b/gcjx/model/fwdtype.cc @@ -21,14 +21,6 @@ #include "typedefs.hh" -static model_class * -maybe_get_erasure (model_class *klass) -{ - if (! klass->type_variable_p () && ! klass->wildcard_p ()) - klass = assert_cast<model_class *> (klass->erasure ()); - return klass; -} - owner<model_forwarding_type> model_forwarding_type::array () { @@ -82,9 +74,6 @@ model_forwarding_simple::resolve (resolution_scope *scope) // FIXME null return resolved_type = classify_type_name (scope, this, name); - model_class *k = dynamic_cast<model_class *> (resolved_type); - if (k) - resolved_type = maybe_get_erasure (k); } void @@ -170,8 +159,7 @@ model_forwarding_inner::resolve (resolution_scope *scope) model_type *r = classify_type_name (scope, this, name, context); if (! r->reference_p ()) throw error ("reference type expected"); - model_class *k = assert_cast<model_class *> (r); - resolved_type = maybe_get_erasure (k); + resolved_type = r; } void diff --git a/gcjx/model/wildcard.cc b/gcjx/model/wildcard.cc index 228ba894bc0..87e08dab9dd 100644 --- a/gcjx/model/wildcard.cc +++ b/gcjx/model/wildcard.cc @@ -51,10 +51,11 @@ model_wildcard::contains_p (model_class *other) if (! other->wildcard_p ()) return false; model_wildcard *w = assert_cast<model_wildcard *> (other); - // FIXME: maybe a bound is ok? - if (w->super_p () != is_super || ! w->get_bound ()) + if (w->super_p () != is_super) return false; model_class *other_bound = w->get_bound (); + if (other_bound == NULL) + other_bound = global->get_compiler ()->java_lang_Object (); if (is_super) return other_bound->assignable_from_p (k); return k->assignable_from_p (other_bound); diff --git a/gcjx/name.cc b/gcjx/name.cc index 2b56d6885f1..082a7913383 100644 --- a/gcjx/name.cc +++ b/gcjx/name.cc @@ -89,6 +89,14 @@ classify_package_or_type_name (resolution_scope *scope, } static model_class * +maybe_get_erasure (model_class *klass) +{ + if (! klass->type_variable_p () && ! klass->wildcard_p ()) + klass = assert_cast<model_class *> (klass->erasure ()); + return klass; +} + +static model_class * check_deprecated (model_class *klass, model_element *request) { assert (klass); @@ -119,7 +127,12 @@ classify_type_name (resolution_scope *scope, // (*i)->error ("could resolve to %1") % (*i); } else if (memtypes.size () == 1) - return check_deprecated (*(memtypes.begin ()), request); + { + model_class *result = check_deprecated (*(memtypes.begin ()), request); + // We only ever want to return the raw type. Parameterization + // is handled elsewhere. + return maybe_get_erasure (result); + } throw type_not_found_error (request->get_location (), "type named %1 is undefined") @@ -186,7 +199,7 @@ classify_type_name (resolution_scope *scope, % qualname; } - return check_deprecated (result, request); + return maybe_get_erasure (check_deprecated (result, request)); } model_field * |