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

Unified Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 23452038: Check cycles in redirecting factories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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: sdk/lib/_internal/compiler/implementation/elements/modelx.dart
diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
index fda82a7406b554fd4bb58c354a211b9125d355f5..6f863955307fdc151c5db7824809c726c89a373a 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
@@ -1275,22 +1275,15 @@ class FunctionElementX extends ElementX implements FunctionElement {
bool get isRedirectingFactory => defaultImplementation != this;
- FunctionElement get redirectionTarget {
- if (this == defaultImplementation) return this;
- var target = defaultImplementation;
- Set<Element> seen = new Set<Element>();
- seen.add(target);
- while (!target.isErroneous() && target != target.defaultImplementation) {
- target = target.defaultImplementation;
- if (seen.contains(target)) {
- // TODO(ahe): This is expedient for now, but it should be
- // checked by the resolver. Keeping http://dartbug.com/3970
- // open to track this.
- throw new SpannableAssertionFailure(
- target, 'redirecting factory leads to cycle');
- }
- }
- return target;
+ /// This field is set by the post process queue when checking for cycles.
+ FunctionElement internalRedirectionTarget;
+ set redirectionTarget(FunctionElement constructor) {
+ assert(constructor != null && internalRedirectionTarget == null);
+ internalRedirectionTarget = constructor;
+ }
+ get redirectionTarget {
+ return internalRedirectionTarget != null ? internalRedirectionTarget
+ : defaultImplementation;
ngeoffray 2013/09/18 11:19:23 This looks weird. Depending on the current stage o
karlklose 2013/09/18 12:30:39 Actually I can decide which of them to return inde
}
InterfaceType computeTargetType(Compiler compiler,

Powered by Google App Engine
This is Rietveld 408576698