| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
| 8 import com.google.common.collect.Lists; | 8 import com.google.common.collect.Lists; |
| 9 import com.google.common.collect.Sets; | 9 import com.google.common.collect.Sets; |
| 10 import com.google.dart.compiler.DartCompilationPhase; | 10 import com.google.dart.compiler.DartCompilationPhase; |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 Modifiers modifiers = node.getModifiers(); | 672 Modifiers modifiers = node.getModifiers(); |
| 673 boolean isFinal = modifiers.isFinal(); | 673 boolean isFinal = modifiers.isFinal(); |
| 674 boolean isTopLevel = ElementKind.of(currentHolder).equals(ElementKind.LIBR
ARY); | 674 boolean isTopLevel = ElementKind.of(currentHolder).equals(ElementKind.LIBR
ARY); |
| 675 boolean isStatic = modifiers.isStatic(); | 675 boolean isStatic = modifiers.isStatic(); |
| 676 | 676 |
| 677 if (expression != null) { | 677 if (expression != null) { |
| 678 resolve(expression); | 678 resolve(expression); |
| 679 // Now, this constant has a type. Save it for future reference. | 679 // Now, this constant has a type. Save it for future reference. |
| 680 Element element = node.getElement(); | 680 Element element = node.getElement(); |
| 681 Type expressionType = expression.getType(); | 681 Type expressionType = expression.getType(); |
| 682 if (expressionType != null && TypeKind.of(element.getType()) == TypeKind
.DYNAMIC) { | 682 if (isFinal && expressionType != null && TypeKind.of(element.getType())
== TypeKind.DYNAMIC) { |
| 683 Type fieldType = Types.makeInferred(expressionType); | 683 Type fieldType = Types.makeInferred(expressionType); |
| 684 Elements.setType(element, fieldType); | 684 Elements.setType(element, fieldType); |
| 685 } | 685 } |
| 686 } else if (isFinal) { | 686 } else if (isFinal) { |
| 687 if (modifiers.isConstant()) { | 687 if (modifiers.isConstant()) { |
| 688 onError(node, ResolverErrorCode.CONST_REQUIRES_VALUE); | 688 onError(node, ResolverErrorCode.CONST_REQUIRES_VALUE); |
| 689 } else if (isStatic) { | 689 } else if (isStatic) { |
| 690 onError(node, ResolverErrorCode.STATIC_FINAL_REQUIRES_VALUE); | 690 onError(node, ResolverErrorCode.STATIC_FINAL_REQUIRES_VALUE); |
| 691 } else if (isTopLevel) { | 691 } else if (isTopLevel) { |
| 692 onError(node, ResolverErrorCode.TOPLEVEL_FINAL_REQUIRES_VALUE); | 692 onError(node, ResolverErrorCode.TOPLEVEL_FINAL_REQUIRES_VALUE); |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2204 ClassElement currentClass = (ClassElement) constructor.getEnclosingEle
ment(); | 2204 ClassElement currentClass = (ClassElement) constructor.getEnclosingEle
ment(); |
| 2205 if (nextClass == currentClass) { | 2205 if (nextClass == currentClass) { |
| 2206 return (ConstructorNodeElement) nextConstructorElement; | 2206 return (ConstructorNodeElement) nextConstructorElement; |
| 2207 } | 2207 } |
| 2208 } | 2208 } |
| 2209 } | 2209 } |
| 2210 } | 2210 } |
| 2211 return null; | 2211 return null; |
| 2212 } | 2212 } |
| 2213 } | 2213 } |
| OLD | NEW |