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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 10831142: Associate the correct type to method receivers (instead of Dynamic type). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
Index: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 10199)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -347,14 +347,17 @@
Value* return_value = for_value.value();
if (FLAG_enable_type_checks) {
- const RawFunction::Kind kind = owner()->parsed_function().function().kind();
- const bool is_implicit_getter =
- (kind == RawFunction::kImplicitGetter) ||
- (kind == RawFunction::kConstImplicitGetter);
- const bool is_static = owner()->parsed_function().function().is_static();
+ const Function& function = owner()->parsed_function().function();
+ const bool is_implicit_dynamic_getter =
+ (!function.is_static() &&
+ ((function.kind() == RawFunction::kImplicitGetter) ||
+ (function.kind() == RawFunction::kConstImplicitGetter)));
// Implicit getters do not need a type check at return, unless they compute
// the initial value of a static field.
- if (is_static || !is_implicit_getter) {
+ // The body of a constructor cannot modify the type of the
+ // constructed instance, which is passed in as an implicit parameter.
+ // However, factories may create an instance of the wrong type.
+ if (!is_implicit_dynamic_getter && !function.IsConstructor()) {
const AbstractType& dst_type =
AbstractType::ZoneHandle(
owner()->parsed_function().function().result_type());

Powered by Google App Engine
This is Rietveld 408576698