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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 2989513002: [VM generic functions] Disallow generic function types as type arguments or bounds. (Closed)
Patch Set: Created 3 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 | « no previous file | tests/language_2/generic_methods_generic_function_result_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
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index 71e9132758a0601c69ee24c2fc3be450d6430c4e..1e877d94021a3319202d6940f52809bb82c721a2 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -796,6 +796,19 @@ intptr_t ClassFinalizer::ExpandAndFinalizeTypeArguments(
if (type_arg.IsMalformed()) {
// Malformed type arguments are mapped to dynamic.
type_arg = Type::DynamicType();
+ } else if (type_arg.IsFunctionType()) {
+ const Function& signature_function =
+ Function::Handle(zone, Type::Cast(type_arg).signature());
+ if (signature_function.IsGeneric()) {
+ const String& type_arg_name =
+ String::Handle(zone, type_arg.UserVisibleName());
+ const String& type_name =
+ String::Handle(zone, type.UserVisibleName());
+ ReportError(cls, type_arg.token_pos(),
+ "generic function type '%s' not allowed as type "
+ "argument of type '%s'",
+ type_arg_name.ToCString(), type_name.ToCString());
+ }
}
full_arguments.SetTypeAt(offset + i, type_arg);
}
@@ -1341,6 +1354,18 @@ void ClassFinalizer::ResolveSignature(const Class& cls,
type_param ^= type_params.TypeAt(i);
type = type_param.bound();
ResolveType(cls, type);
+ if (type.IsFunctionType()) {
+ const Function& signature_function =
+ Function::Handle(Type::Cast(type).signature());
+ if (signature_function.IsGeneric()) {
+ const String& type_name = String::Handle(type.UserVisibleName());
+ const String& type_param_name = String::Handle(type_param.name());
+ ReportError(cls, type.token_pos(),
+ "generic function type '%s' not allowed as bound of "
+ "function type parameter '%s'",
+ type_name.ToCString(), type_param_name.ToCString());
+ }
+ }
}
}
// Resolve result type.
@@ -1459,6 +1484,18 @@ void ClassFinalizer::ResolveUpperBounds(const Class& cls) {
type_param ^= type_params.TypeAt(i);
bound = type_param.bound();
ResolveType(cls, bound);
+ if (bound.IsFunctionType()) {
+ const Function& signature_function =
+ Function::Handle(Type::Cast(bound).signature());
+ if (signature_function.IsGeneric()) {
+ const String& bound_name = String::Handle(bound.UserVisibleName());
+ const String& type_param_name = String::Handle(type_param.name());
+ ReportError(cls, bound.token_pos(),
+ "generic function type '%s' not allowed as bound of "
+ "class type parameter '%s'",
+ bound_name.ToCString(), type_param_name.ToCString());
+ }
+ }
}
}
« no previous file with comments | « no previous file | tests/language_2/generic_methods_generic_function_result_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698