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

Unified Diff: runtime/lib/mirrors.cc

Issue 26344006: Substitution for type variables in mirrors on instantiated generics. (Closed) Base URL: https://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
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | runtime/lib/mirrors_impl.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index be30b5deb8d1184d08c65f9bbff634554e7a01b2..0247923909e0903d83e0cd63c7d234c93fe22af4 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -869,9 +869,32 @@ DEFINE_NATIVE_ENTRY(ClassMirror_library, 1) {
DEFINE_NATIVE_ENTRY(ClassMirror_supertype, 1) {
- GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
- const Class& klass = Class::Handle(ref.GetClassReferent());
- return klass.super_type();
+ GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
+ const Class& cls = Class::Handle(type.type_class());
+ AbstractType& super_type = AbstractType::Handle(cls.super_type());
+ return super_type.raw();
regis 2013/10/09 15:46:51 You can spare a handle: return cls.super_type();
rmacnak 2013/10/11 01:04:22 Done.
+}
+
+DEFINE_NATIVE_ENTRY(ClassMirror_supertype_instantiated, 1) {
+ GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
+ const Class& cls = Class::Handle(type.type_class());
+ AbstractType& super_type = AbstractType::Handle(cls.super_type());
+ AbstractType& result = AbstractType::Handle(super_type.raw());
+
+ ASSERT(super_type.IsType() || super_type.IsMixinAppType());
regis 2013/10/09 15:46:51 That is not correct. This could also be a BoundedT
rmacnak 2013/10/11 01:04:22 We never see a BoundType here even with the additi
+ if (!super_type.IsInstantiated()) {
+ // Why should mixin app types always be instantiated?
regis 2013/10/09 15:46:51 MixinAppType live at compile time only.
rmacnak 2013/10/11 01:04:22 ASSERT now excludes MixinAppType
+ ASSERT(super_type.IsType());
regis 2013/10/09 15:46:51 || super_type.IsBoundedType()
+ AbstractTypeArguments& type_args =
+ AbstractTypeArguments::Handle(type.arguments());
+ Error& error = Error::Handle();
+ result ^= super_type.InstantiateFrom(type_args, &error);
regis 2013/10/09 15:46:51 Instantiating is correct, but using a prefix of ty
+ // Is result canonical?
regis 2013/10/09 15:46:51 No, result is finalized, but not canonical.
+ ASSERT(error.IsNull());
regis 2013/10/09 15:46:51 You could get a bound error if the instance was cr
rmacnak 2013/10/11 01:04:22 Added ThrowInvokeError to be cautious.
+ ASSERT(result.IsType());
+ }
+
+ return result.raw();
}
@@ -1086,6 +1109,19 @@ DEFINE_NATIVE_ENTRY(TypeVariableMirror_upper_bound, 1) {
}
+DEFINE_NATIVE_ENTRY(TypeVariableMirror_instantiate_from, 2) {
+ GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Type, instantiator, arguments->NativeArgAt(1));
+ AbstractTypeArguments& type_args =
+ AbstractTypeArguments::Handle(instantiator.arguments());
+ Error& error = Error::Handle();
+ AbstractType& result =
+ AbstractType::Handle(param.InstantiateFrom(type_args, &error));
+ ASSERT(error.IsNull());
regis 2013/10/09 15:46:51 Why are you certain you will not get a bound error
rmacnak 2013/10/11 01:04:22 The instantiator should always be the type of the
+ return result.raw();
+}
+
+
DEFINE_NATIVE_ENTRY(InstanceMirror_invoke, 5) {
// Argument 0 is the mirror, which is unused by the native. It exists
// because this native is an instance method in order to be polymorphic
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | runtime/lib/mirrors_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698