OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
6 | 6 |
7 import com.google.dart.compiler.DartCompilerContext; | 7 import com.google.dart.compiler.DartCompilerContext; |
8 import com.google.dart.compiler.DartCompilerErrorCode; | 8 import com.google.dart.compiler.DartCompilerErrorCode; |
9 import com.google.dart.compiler.ErrorCode; | 9 import com.google.dart.compiler.ErrorCode; |
10 import com.google.dart.compiler.ast.DartClass; | 10 import com.google.dart.compiler.ast.DartClass; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 return (ConstructorElement) e; | 216 return (ConstructorElement) e; |
217 } | 217 } |
218 // If the constructor name resolves to a class or there was an error, | 218 // If the constructor name resolves to a class or there was an error, |
219 // create the unnamed constructor. | 219 // create the unnamed constructor. |
220 return Elements.constructorFromMethodNode(method, "", (ClassElement) curre ntHolder, | 220 return Elements.constructorFromMethodNode(method, "", (ClassElement) curre ntHolder, |
221 (ClassElement) e); | 221 (ClassElement) e); |
222 } | 222 } |
223 | 223 |
224 private FieldElement buildField(DartField fieldNode, Type type) { | 224 private FieldElement buildField(DartField fieldNode, Type type) { |
225 assert !fieldNode.getModifiers().isAbstractField(); | 225 assert !fieldNode.getModifiers().isAbstractField(); |
226 Modifiers modifiers = fieldNode.getModifiers(); | |
227 if (modifiers.isFinal() && (modifiers.isStatic() || context == topLevelCon text)) { | |
228 // final toplevel fields are implicitly compile-time constants. | |
229 modifiers = modifiers.makeConstant(); | |
floitsch
2011/10/14 14:36:58
This sounds wrong.
zundel
2011/10/14 20:59:52
I'm still changing the modifiers. Final and Const
| |
230 } | |
226 FieldElement fieldElement = fieldNode.getSymbol(); | 231 FieldElement fieldElement = fieldNode.getSymbol(); |
227 if (fieldElement == null) { | 232 if (fieldElement == null) { |
228 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, fieldNod e.getModifiers()); | 233 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, modifier s); |
229 addField(currentHolder, fieldElement); | 234 addField(currentHolder, fieldElement); |
230 } else { | 235 } else { |
231 // This is a top-level element, and an element was already created in | 236 // This is a top-level element, and an element was already created in |
232 // TopLevelElementBuilder. | 237 // TopLevelElementBuilder. |
233 Elements.addField(currentHolder, fieldElement); | 238 Elements.addField(currentHolder, fieldElement); |
234 assertTopLevel(fieldNode); | 239 assertTopLevel(fieldNode); |
235 } | 240 } |
236 fieldElement.setType(type); | 241 fieldElement.setType(type); |
237 return recordElement(fieldNode, fieldElement); | 242 return recordElement(fieldNode, fieldElement); |
238 } | 243 } |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 } | 489 } |
485 } | 490 } |
486 return element; | 491 return element; |
487 } | 492 } |
488 | 493 |
489 void resolutionError(DartNode node, ErrorCode errorCode, Object... arguments ) { | 494 void resolutionError(DartNode node, ErrorCode errorCode, Object... arguments ) { |
490 topLevelContext.resolutionError(node, errorCode, arguments); | 495 topLevelContext.resolutionError(node, errorCode, arguments); |
491 } | 496 } |
492 } | 497 } |
493 } | 498 } |
OLD | NEW |