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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 19997003: Implement more restrictive checking of typedefs illegally referring to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | tests/language/function_type_alias6_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 25374)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -1663,6 +1663,36 @@
}
+// Helper function called by IsAliasCycleFree.
+bool ClassFinalizer::IsParameterTypeCycleFree(
+ const Class& cls,
+ const AbstractType& type,
+ GrowableArray<intptr_t>* visited) {
+ ASSERT(visited != NULL);
+ ResolveType(cls, type, kCanonicalize);
+ if (type.IsType() && !type.IsMalformed()) {
+ const Class& type_class = Class::Handle(type.type_class());
+ if (!type_class.is_type_finalized() &&
+ type_class.IsSignatureClass() &&
+ !IsAliasCycleFree(type_class, visited)) {
+ return false;
+ }
+ const AbstractTypeArguments& type_args = AbstractTypeArguments::Handle(
+ type.arguments());
+ if (!type_args.IsNull()) {
+ 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)) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+
// Returns false if the function type alias illegally refers to itself.
bool ClassFinalizer::IsAliasCycleFree(const Class& cls,
GrowableArray<intptr_t>* visited) {
@@ -1682,27 +1712,15 @@
const Function& function = Function::Handle(cls.signature_function());
// Check class of result type.
AbstractType& type = AbstractType::Handle(function.result_type());
- ResolveType(cls, type, kCanonicalize);
- if (type.IsType() && !type.IsMalformed()) {
- const Class& type_class = Class::Handle(type.type_class());
- if (!type_class.is_type_finalized() &&
- type_class.IsSignatureClass() &&
- !IsAliasCycleFree(type_class, visited)) {
- return false;
- }
+ if (!IsParameterTypeCycleFree(cls, type, visited)) {
+ return false;
}
// Check classes of formal parameter types.
const intptr_t num_parameters = function.NumParameters();
for (intptr_t i = 0; i < num_parameters; i++) {
type = function.ParameterTypeAt(i);
- ResolveType(cls, type, kCanonicalize);
- if (type.IsType() && !type.IsMalformed()) {
- const Class& type_class = Class::Handle(type.type_class());
- if (!type_class.is_type_finalized() &&
- type_class.IsSignatureClass() &&
- !IsAliasCycleFree(type_class, visited)) {
- return false;
- }
+ if (!IsParameterTypeCycleFree(cls, type, visited)) {
+ return false;
}
}
visited->RemoveLast();
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | tests/language/function_type_alias6_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698