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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 25478009: Handle compile-time constness for conditionals and type literal calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 586d28f590022f78ad7b015f64dabd343bb84d13..ff0bd625d740155215f16b63e2f270c39e1419f3 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -477,11 +477,12 @@ class ResolverTask extends CompilerTask {
compiler.reportError(element, MessageKind.CONST_WITHOUT_INITIALIZER);
}
+ visitor.addPostProcessAction(element, () {
karlklose 2013/10/02 11:08:55 Add a TODO to check if we need a constant.
Johnni Winther 2013/10/02 12:39:33 Reverted this change. The constant is only needed
+ compiler.constantHandler.compileVariable(
+ element, isConst: element.modifiers.isConst());
+ });
+
if (Elements.isStaticOrTopLevelField(element)) {
- visitor.addPostProcessAction(element, () {
- compiler.constantHandler.compileVariable(
- element, isConst: element.modifiers.isConst());
- });
if (tree.asSendSet() != null) {
if (!element.modifiers.isConst()) {
// TODO(johnniwinther): Determine the const-ness eagerly to avoid
@@ -2441,7 +2442,9 @@ class ResolverVisitor extends MappingVisitor<Element> {
// type literal.
mapping.setType(node, compiler.typeClass.computeType(compiler));
world.registerTypeLiteral(target, mapping);
- analyzeConstant(node);
+
+ // Don't try to make constants of calls to type literals.
+ analyzeConstant(node, isConst: !node.isCall);
}
}
@@ -2892,11 +2895,10 @@ class ResolverVisitor extends MappingVisitor<Element> {
return null;
}
- void analyzeConstant(Node node) {
+ void analyzeConstant(Node node, {bool isConst: true}) {
addPostProcessAction(enclosingElement, () {
- mapping.setConstant(node,
- compiler.constantHandler.compileNodeWithDefinitions(
- node, mapping, isConst: true));
+ compiler.constantHandler.compileNodeWithDefinitions(
+ node, mapping, isConst: isConst);
});
}

Powered by Google App Engine
This is Rietveld 408576698