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

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 1b6f35e2f752de87a56a95ce1d1d92008d07eff4..980a76fee8295e7d902319ccf5a07870e12a1ae0 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
@@ -1279,22 +1279,21 @@ 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');
- }
+ /// 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 {
+ if (Elements.isErroneousElement(defaultImplementation)) {
+ return defaultImplementation;
}
- return target;
+ assert(!isRedirectingFactory || internalRedirectionTarget);
+ return isRedirectingFactory ? internalRedirectionTarget
+ : defaultImplementation;
ngeoffray 2013/09/18 12:52:07 Please return null instead of defaultImplementatio
}
InterfaceType computeTargetType(Compiler compiler,

Powered by Google App Engine
This is Rietveld 408576698