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

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: Address comments. Created 6 years, 4 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') | no next file with comments »
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 b4048bdb8d3444d0286096947a2b3b11c9ad54e8..109e3df07d4b57b78d3722a7517baba0a9f81472 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.
+ // 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698