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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 422573004: Fix type-checks for reflective redirection constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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/lib/lib.status » ('j') | tests/lib/mirrors/redirecting_factory_different_type_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 5ab75da704e05bf9e84f2a2372503a048539ceee..9e2a04429aebd8a4a2a7ee9b068345a592b9d46f 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -2176,9 +2176,25 @@ class SsaBuilder extends ResolvedVisitor {
return;
}
}
- HInstruction newParameter = potentiallyCheckType(
- localsHandler.directLocals[parameterElement],
- parameterElement.type);
+ HInstruction newParameter =
+ localsHandler.directLocals[parameterElement];
+ if (!element.isConstructor ||
+ !(element as ConstructorElement).isRedirectingFactory) {
+ // Redirection factories must not check their argument types.
ahe 2014/07/27 09:43:31 I'm having a hard time finding this explicitly sta
Johnni Winther 2014/08/04 06:58:03 It is in the spec, implicitly. I even asked Gilad
+ // Example:
+ //
+ // class A {
+ // A(String foo) = A.b;
+ // A(int foo) { print(foo); }
+ // }
+ // main() {
+ // new A(499); // valid even in checked mode.
+ // new A("foo"); // invalid in checked mode.
+ //
+ // Only the final target is allowed to check for the argument types.
+ newParameter =
+ potentiallyCheckType(newParameter, parameterElement.type);
+ }
localsHandler.directLocals[parameterElement] = newParameter;
});
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | tests/lib/mirrors/redirecting_factory_different_type_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698