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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library elements.modelx; 5 library elements.modelx;
6 6
7 import 'dart:collection' show LinkedHashMap; 7 import 'dart:collection' show LinkedHashMap;
8 8
9 import 'elements.dart'; 9 import 'elements.dart';
10 import '../../compiler.dart' as api; 10 import '../../compiler.dart' as api;
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 : super(name, kind, enclosing) { 1272 : super(name, kind, enclosing) {
1273 assert(modifiers != null); 1273 assert(modifiers != null);
1274 defaultImplementation = this; 1274 defaultImplementation = this;
1275 } 1275 }
1276 1276
1277 bool get isPatched => patch != null; 1277 bool get isPatched => patch != null;
1278 bool get isPatch => origin != null; 1278 bool get isPatch => origin != null;
1279 1279
1280 bool get isRedirectingFactory => defaultImplementation != this; 1280 bool get isRedirectingFactory => defaultImplementation != this;
1281 1281
1282 FunctionElement get redirectionTarget { 1282 /// This field is set by the post process queue when checking for cycles.
1283 if (this == defaultImplementation) return this; 1283 FunctionElement internalRedirectionTarget;
1284 var target = defaultImplementation; 1284
1285 Set<Element> seen = new Set<Element>(); 1285 set redirectionTarget(FunctionElement constructor) {
1286 seen.add(target); 1286 assert(constructor != null && internalRedirectionTarget == null);
1287 while (!target.isErroneous() && target != target.defaultImplementation) { 1287 internalRedirectionTarget = constructor;
1288 target = target.defaultImplementation; 1288 }
1289 if (seen.contains(target)) { 1289
1290 // TODO(ahe): This is expedient for now, but it should be 1290 get redirectionTarget {
1291 // checked by the resolver. Keeping http://dartbug.com/3970 1291 if (Elements.isErroneousElement(defaultImplementation)) {
1292 // open to track this. 1292 return defaultImplementation;
1293 throw new SpannableAssertionFailure(
1294 target, 'redirecting factory leads to cycle');
1295 }
1296 } 1293 }
1297 return target; 1294 assert(!isRedirectingFactory || internalRedirectionTarget);
1295 return isRedirectingFactory ? internalRedirectionTarget
1296 : defaultImplementation;
ngeoffray 2013/09/18 12:52:07 Please return null instead of defaultImplementatio
1298 } 1297 }
1299 1298
1300 InterfaceType computeTargetType(Compiler compiler, 1299 InterfaceType computeTargetType(Compiler compiler,
1301 InterfaceType newType) { 1300 InterfaceType newType) {
1302 if (!isRedirectingFactory) return newType; 1301 if (!isRedirectingFactory) return newType;
1303 ClassElement targetClass = getEnclosingClass(); 1302 ClassElement targetClass = getEnclosingClass();
1304 TreeElements treeElements = 1303 TreeElements treeElements =
1305 compiler.enqueuer.resolution.getCachedElements( 1304 compiler.enqueuer.resolution.getCachedElements(
1306 declaration); 1305 declaration);
1307 FunctionExpression functionNode = parseNode(compiler); 1306 FunctionExpression functionNode = parseNode(compiler);
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 2220
2222 MetadataAnnotation ensureResolved(Compiler compiler) { 2221 MetadataAnnotation ensureResolved(Compiler compiler) {
2223 if (resolutionState == STATE_NOT_STARTED) { 2222 if (resolutionState == STATE_NOT_STARTED) {
2224 compiler.resolver.resolveMetadataAnnotation(this); 2223 compiler.resolver.resolveMetadataAnnotation(this);
2225 } 2224 }
2226 return this; 2225 return this;
2227 } 2226 }
2228 2227
2229 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2228 String toString() => 'MetadataAnnotation($value, $resolutionState)';
2230 } 2229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698