Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: runtime/vm/class_finalizer.cc

Issue 49853004: Implement stricter rule about self referencing typedefs (fix issue 13675). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 29405)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -584,12 +584,12 @@
// Such legal self-references occur with F-bounded quantification.
// Example 1: class Derived extends Base<Derived>.
// The type 'Derived' forms a cycle by pointing to itself via its
- // flattened type argument vector: Derived[Base[Derived[Base[...]]]]
- // We break the cycle as follows: Derived[Base[Derived[dynamic]]]
+ // flattened type argument vector: Derived[Derived[...]]
+ // We break the cycle as follows: Derived[Derived[dynamic]]
// Example 2: class Derived extends Base<Middle<Derived>> results in
- // Derived[Base[Middle[Derived[dynamic]]]]
+ // Derived[Middle[Derived[dynamic]]]
// Example 3: class Derived<T> extends Base<Derived<T>> results in
- // Derived[Base[Derived[dynamic]], T].
+ // Derived[Derived[dynamic], T].
ASSERT(super_type_args.IsNull()); // Same as a vector of dynamic.
} else {
super_type ^= FinalizeType(cls, super_type, finalization);
@@ -2127,7 +2127,7 @@
// Helper function called by IsAliasCycleFree.
-bool ClassFinalizer::IsParameterTypeCycleFree(
+bool ClassFinalizer::IsTypeCycleFree(
const Class& cls,
const AbstractType& type,
GrowableArray<intptr_t>* visited) {
@@ -2146,7 +2146,7 @@
AbstractType& type_arg = AbstractType::Handle();
for (intptr_t i = 0; i < type_args.Length(); i++) {
type_arg = type_args.TypeAt(i);
- if (!IsParameterTypeCycleFree(cls, type_arg, visited)) {
+ if (!IsTypeCycleFree(cls, type_arg, visited)) {
return false;
}
}
@@ -2170,19 +2170,35 @@
}
}
- // Visit the result type and parameter types of this signature type.
+ // Visit the bounds, result type, and parameter types of this signature type.
visited->Add(cls.id());
+ AbstractType& type = AbstractType::Handle();
+
+ // Check the bounds of this signature type.
+ const intptr_t num_type_params = cls.NumTypeParameters();
+ TypeParameter& type_param = TypeParameter::Handle();
+ const AbstractTypeArguments& type_params =
+ AbstractTypeArguments::Handle(cls.type_parameters());
+ ASSERT((type_params.IsNull() && (num_type_params == 0)) ||
+ (type_params.Length() == num_type_params));
+ for (intptr_t i = 0; i < num_type_params; i++) {
+ type_param ^= type_params.TypeAt(i);
+ type = type_param.bound();
+ if (!IsTypeCycleFree(cls, type, visited)) {
+ return false;
+ }
+ }
+ // Check the result type of the function of this signature type.
const Function& function = Function::Handle(cls.signature_function());
- // Check class of result type.
- AbstractType& type = AbstractType::Handle(function.result_type());
- if (!IsParameterTypeCycleFree(cls, type, visited)) {
+ type = function.result_type();
+ if (!IsTypeCycleFree(cls, type, visited)) {
return false;
}
- // Check classes of formal parameter types.
+ // Check the formal parameter types of the function of this signature type.
const intptr_t num_parameters = function.NumParameters();
for (intptr_t i = 0; i < num_parameters; i++) {
type = function.ParameterTypeAt(i);
- if (!IsParameterTypeCycleFree(cls, type, visited)) {
+ if (!IsTypeCycleFree(cls, type, visited)) {
return false;
}
}
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698