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

Side by Side Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 10703046: Issue 3753. Support for @deprecated annotation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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) 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.type; 5 package com.google.dart.compiler.type;
6 6
7 import com.google.common.annotations.VisibleForTesting; 7 import com.google.common.annotations.VisibleForTesting;
8 import com.google.common.base.Joiner; 8 import com.google.common.base.Joiner;
9 import com.google.common.base.Objects; 9 import com.google.common.base.Objects;
10 import com.google.common.collect.ArrayListMultimap; 10 import com.google.common.collect.ArrayListMultimap;
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 } 1217 }
1218 DartNode target = node.getTarget(); 1218 DartNode target = node.getTarget();
1219 Type receiver = nonVoidTypeOf(target); 1219 Type receiver = nonVoidTypeOf(target);
1220 Member member = lookupMember(receiver, name, nameNode); 1220 Member member = lookupMember(receiver, name, nameNode);
1221 if (member != null) { 1221 if (member != null) {
1222 Element methodElement = member.getElement(); 1222 Element methodElement = member.getElement();
1223 node.setElement(methodElement); 1223 node.setElement(methodElement);
1224 if (nameNode != null) { 1224 if (nameNode != null) {
1225 nameNode.setElement(methodElement); 1225 nameNode.setElement(methodElement);
1226 } 1226 }
1227 // @deprecated
1228 if (methodElement != null && methodElement.getMetadata().isDeprecated()) {
Brian Wilkerson 2012/06/29 16:17:49 This needs to be copied into visitBinaryExpression
scheglov 2012/06/29 20:11:57 Done.
1229 onError(nameNode, TypeErrorCode.DEPRECATED_ELEMENT, name);
1230 }
1227 } 1231 }
1228 FunctionType methodType = getMethodType(receiver, member, name, nameNode); 1232 FunctionType methodType = getMethodType(receiver, member, name, nameNode);
1229 return checkInvocation(node, nameNode, name, methodType); 1233 return checkInvocation(node, nameNode, name, methodType);
1230 } 1234 }
1231 1235
1232 @Override 1236 @Override
1233 public Type visitSuperConstructorInvocation(DartSuperConstructorInvocation n ode) { 1237 public Type visitSuperConstructorInvocation(DartSuperConstructorInvocation n ode) {
1234 return checkConstructorForwarding(node, node.getElement()); 1238 return checkConstructorForwarding(node, node.getElement());
1235 } 1239 }
1236 1240
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 return dynamicType; 1951 return dynamicType;
1948 } 1952 }
1949 element = member.getElement(); 1953 element = member.getElement();
1950 node.setElement(element); 1954 node.setElement(element);
1951 Modifiers modifiers = element.getModifiers(); 1955 Modifiers modifiers = element.getModifiers();
1952 if (modifiers.isStatic()) { 1956 if (modifiers.isStatic()) {
1953 return typeError(node.getName(), 1957 return typeError(node.getName(),
1954 TypeErrorCode.STATIC_MEMBER_ACCESSED_THROUGH_INSTANCE, 1958 TypeErrorCode.STATIC_MEMBER_ACCESSED_THROUGH_INSTANCE,
1955 name, element.getName()); 1959 name, element.getName());
1956 } 1960 }
1961 // @deprecated
1962 if (element != null && element.getMetadata().isDeprecated()) {
1963 onError(node.getName(), TypeErrorCode.DEPRECATED_ELEMENT, name);
1964 }
1965 // analyze Element
1957 switch (element.getKind()) { 1966 switch (element.getKind()) {
1958 case DYNAMIC: 1967 case DYNAMIC:
1959 return dynamicType; 1968 return dynamicType;
1960 case CONSTRUCTOR: 1969 case CONSTRUCTOR:
1961 return typeError(node.getName(), TypeErrorCode.MEMBER_IS_A_CONSTRUCTOR , 1970 return typeError(node.getName(), TypeErrorCode.MEMBER_IS_A_CONSTRUCTOR ,
1962 name, element.getName()); 1971 name, element.getName());
1963 1972
1964 case METHOD: 1973 case METHOD:
1965 return member.getType(); 1974 return member.getType();
1966 1975
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 // special support for "assert" 2216 // special support for "assert"
2208 if (Elements.isArtificialAssertMethod(element)) { 2217 if (Elements.isArtificialAssertMethod(element)) {
2209 if (node.getArguments().size() == 1) { 2218 if (node.getArguments().size() == 1) {
2210 DartExpression condition = node.getArguments().get(0); 2219 DartExpression condition = node.getArguments().get(0);
2211 checkAssertCondition(condition); 2220 checkAssertCondition(condition);
2212 } else { 2221 } else {
2213 onError(node, TypeErrorCode.ASSERT_NUMBER_ARGUMENTS); 2222 onError(node, TypeErrorCode.ASSERT_NUMBER_ARGUMENTS);
2214 } 2223 }
2215 return voidType; 2224 return voidType;
2216 } 2225 }
2226 // @deprecated
2227 if (element != null && element.getMetadata().isDeprecated()) {
2228 onError(target, TypeErrorCode.DEPRECATED_ELEMENT, name);
2229 }
2217 // normal invocation 2230 // normal invocation
2218 Type type; 2231 Type type;
2219 switch (ElementKind.of(element)) { 2232 switch (ElementKind.of(element)) {
2220 case FIELD: 2233 case FIELD:
2221 case METHOD: 2234 case METHOD:
2222 type = typeAsMemberOf(element, currentClass); 2235 type = typeAsMemberOf(element, currentClass);
2223 break; 2236 break;
2224 case NONE: 2237 case NONE:
2225 if (!target.isResolutionAlreadyReportedThatTheMethodCouldNotBeFound()) { 2238 if (!target.isResolutionAlreadyReportedThatTheMethodCouldNotBeFound()) {
2226 onError(target, TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, current Class, target); 2239 onError(target, TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, current Class, target);
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 for (VariableElement v : parameters) { 2846 for (VariableElement v : parameters) {
2834 if (v.isNamed()) { 2847 if (v.isNamed()) {
2835 named.add(v); 2848 named.add(v);
2836 } 2849 }
2837 } 2850 }
2838 return named; 2851 return named;
2839 } 2852 }
2840 } 2853 }
2841 } 2854 }
2842 } 2855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698