| Index: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| index 209b9b5bebf4d7002ff952ffb694770aa050d497..9d3d327e2038931988ba908fcc361e42beb9fb41 100644
|
| --- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| +++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| @@ -312,8 +312,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| HasSourceInfo problemTarget = getOperatorHasSourceInfo(node);
|
| Member member = lookupMember(lhsType, methodName, problemTarget);
|
| if (member != null) {
|
| - node.setElement(member.getElement());
|
| + Element element = member.getElement();
|
| + node.setElement(element);
|
| FunctionType methodType = getMethodType(lhsType, member, methodName, diagnosticNode);
|
| + checkDeprecated(problemTarget, element);
|
| Type returnType = checkInvocation(Collections.<DartExpression> singletonList(rhs),
|
| diagnosticNode, methodName, methodType);
|
| // tweak return type for int/int and int/double operators
|
| @@ -1228,7 +1230,9 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
|
|
| @Override
|
| public Type visitFunctionObjectInvocation(DartFunctionObjectInvocation node) {
|
| - node.setElement(functionType.getElement());
|
| + ClassElement element = functionType.getElement();
|
| + node.setElement(element);
|
| + checkDeprecated(node, element);
|
| return checkInvocation(node, node, null, typeOf(node.getTarget()));
|
| }
|
|
|
| @@ -1240,6 +1244,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| if (element != null && (element.getModifiers().isStatic()
|
| || Elements.isTopLevel(element))) {
|
| node.setElement(element);
|
| + checkDeprecated(nameNode, element);
|
| return checkInvocation(node, nameNode, name, element.getType());
|
| }
|
| DartNode target = node.getTarget();
|
| @@ -1252,6 +1257,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| nameNode.setElement(methodElement);
|
| }
|
| }
|
| + checkDeprecated(nameNode, nameNode.getElement());
|
| FunctionType methodType = getMethodType(receiver, member, name, nameNode);
|
| return checkInvocation(node, nameNode, name, methodType);
|
| }
|
| @@ -1267,6 +1273,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| return voidType;
|
| } else {
|
| node.setElement(element);
|
| + checkDeprecated(node, element);
|
| checkInvocation(node, node, null, typeAsMemberOf(element, currentClass));
|
| return voidType;
|
| }
|
| @@ -1874,7 +1881,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| }
|
| List<Type> arguments = ifaceType.getArguments();
|
| ftype = (FunctionType) ftype.subst(arguments, substParams);
|
| - checkInvocation(node, node, null, ftype);
|
| + checkDeprecated(getConstructorNameNode(node), constructorElement);
|
| + checkInvocation(node, node, constructorElement.getName(), ftype);
|
| }
|
| }
|
| type.getClass(); // quick null check
|
| @@ -1981,6 +1989,11 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| TypeErrorCode.STATIC_MEMBER_ACCESSED_THROUGH_INSTANCE,
|
| name, element.getName());
|
| }
|
| + // @deprecated
|
| + if (element != null && element.getMetadata().isDeprecated()) {
|
| + onError(node.getName(), TypeErrorCode.DEPRECATED_ELEMENT, name);
|
| + }
|
| + // analyze Element
|
| switch (element.getKind()) {
|
| case DYNAMIC:
|
| return dynamicType;
|
| @@ -2175,8 +2188,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| HasSourceInfo problemTarget = getOperatorHasSourceInfo(node);
|
| Member member = lookupMember(type, name, problemTarget);
|
| if (member != null) {
|
| - node.setElement(member.getElement());
|
| + Element element = member.getElement();
|
| + node.setElement(element);
|
| FunctionType methodType = getMethodType(type, member, name, node);
|
| + checkDeprecated(problemTarget, element);
|
| return checkInvocation(Collections.<DartExpression>emptyList(), node, name, methodType);
|
| } else {
|
| return dynamicType;
|
| @@ -2266,17 +2281,27 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| }
|
| break;
|
| }
|
| + checkDeprecated(target, element);
|
| return checkInvocation(node, target, name, type);
|
| }
|
|
|
| + /**
|
| + * Report warning if given {@link Element} is deprecated.
|
| + */
|
| + private void checkDeprecated(HasSourceInfo nameNode, Element element) {
|
| + if (element != null && element.getMetadata().isDeprecated()) {
|
| + onError(nameNode, TypeErrorCode.DEPRECATED_ELEMENT, element);
|
| + }
|
| + }
|
| +
|
| private Type checkInvocation(DartInvocation node, DartNode diagnosticNode, String name,
|
| Type type) {
|
| List<DartExpression> argumentNodes = node.getArguments();
|
| return checkInvocation(argumentNodes, diagnosticNode, name, type);
|
| }
|
|
|
| - private Type checkInvocation(List<DartExpression> argumentNodes,
|
| - DartNode diagnosticNode, String name, Type type) {
|
| + private Type checkInvocation(List<DartExpression> argumentNodes, DartNode diagnosticNode,
|
| + String name, Type type) {
|
| // Prepare argument types.
|
| List<Type> argumentTypes = Lists.newArrayListWithCapacity(argumentNodes.size());
|
| for (DartExpression argumentNode : argumentNodes) {
|
| @@ -2538,6 +2563,27 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| return hasFunctionTypeAliasReference(visited, target, current);
|
| }
|
|
|
| + /**
|
| + * @return the {@link DartIdentifier} corresponding to the name of constructor.
|
| + */
|
| + public static DartIdentifier getConstructorNameNode(DartNewExpression node) {
|
| + DartNode constructor = node.getConstructor();
|
| + return getConstructorNameNode(constructor);
|
| + }
|
| +
|
| + /**
|
| + * @return the {@link DartIdentifier} corresponding to the name of constructor.
|
| + */
|
| + public static DartIdentifier getConstructorNameNode(DartNode constructor) {
|
| + if (constructor instanceof DartPropertyAccess) {
|
| + return ((DartPropertyAccess) constructor).getName();
|
| + } else if (constructor instanceof DartTypeNode) {
|
| + return getConstructorNameNode(((DartTypeNode) constructor).getIdentifier());
|
| + } else {
|
| + return (DartIdentifier) constructor;
|
| + }
|
| + }
|
| +
|
| @Override
|
| public Type visitIntegerLiteral(DartIntegerLiteral node) {
|
| return typeOfLiteral(node);
|
|
|