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

Side by Side Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 10825190: Don't infer non-final field types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tests for 'const' Created 8 years, 4 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
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698