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

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

Issue 10825135: Issue 4238. Infer Element subclass from query() parameter (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 if (element != null && (element.getModifiers().isStatic() 1241 if (element != null && (element.getModifiers().isStatic()
1242 || Elements.isTopLevel(element))) { 1242 || Elements.isTopLevel(element))) {
1243 node.setElement(element); 1243 node.setElement(element);
1244 checkDeprecated(nameNode, element); 1244 checkDeprecated(nameNode, element);
1245 return checkInvocation(node, nameNode, name, element.getType()); 1245 return checkInvocation(node, nameNode, name, element.getType());
1246 } 1246 }
1247 DartNode target = node.getTarget(); 1247 DartNode target = node.getTarget();
1248 Type receiver = nonVoidTypeOf(target); 1248 Type receiver = nonVoidTypeOf(target);
1249 Member member = lookupMember(receiver, name, nameNode); 1249 Member member = lookupMember(receiver, name, nameNode);
1250 if (member != null) { 1250 if (member != null) {
1251 Element methodElement = member.getElement(); 1251 element = member.getElement();
1252 checkIllegalPrivateAccess(node.getFunctionName(), methodElement, name); 1252 checkIllegalPrivateAccess(node.getFunctionName(), element, name);
1253 node.setElement(methodElement); 1253 node.setElement(element);
1254 if (nameNode != null) { 1254 if (nameNode != null) {
1255 nameNode.setElement(methodElement); 1255 nameNode.setElement(element);
1256 } 1256 }
1257 } 1257 }
1258 checkDeprecated(nameNode, nameNode.getElement()); 1258 checkDeprecated(nameNode, nameNode.getElement());
1259 FunctionType methodType = getMethodType(receiver, member, name, nameNode); 1259 FunctionType methodType = getMethodType(receiver, member, name, nameNode);
1260 return checkInvocation(node, nameNode, name, methodType); 1260 Type returnType = checkInvocation(node, nameNode, name, methodType);
1261 returnType = ExternalTypeAnalyzers.resolve(types, node, element, returnTyp e);
1262 return returnType;
1261 } 1263 }
1262 1264
1263 private void checkIllegalPrivateAccess(DartNode diagnosticNode, Element elem ent, String name) { 1265 private void checkIllegalPrivateAccess(DartNode diagnosticNode, Element elem ent, String name) {
1264 if (DartIdentifier.isPrivateName(name)) { 1266 if (DartIdentifier.isPrivateName(name)) {
1265 if (element != null) { 1267 if (element != null) {
1266 Element enclosingLibrary = Elements.getLibraryElement(currentMethod); 1268 Element enclosingLibrary = Elements.getLibraryElement(currentMethod);
1267 Element identifierEnclosingLibrary = Elements.getLibraryElement(elemen t); 1269 Element identifierEnclosingLibrary = Elements.getLibraryElement(elemen t);
1268 if (!enclosingLibrary.equals(identifierEnclosingLibrary)) { 1270 if (!enclosingLibrary.equals(identifierEnclosingLibrary)) {
1269 onError(diagnosticNode, TypeErrorCode.ILLEGAL_ACCESS_TO_PRIVATE, nam e); 1271 onError(diagnosticNode, TypeErrorCode.ILLEGAL_ACCESS_TO_PRIVATE, nam e);
1270 } 1272 }
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 InterfaceType interfaceType = (InterfaceType) type; 2297 InterfaceType interfaceType = (InterfaceType) type;
2296 Element callElement = interfaceType.getElement().lookupLocalElement( "call"); 2298 Element callElement = interfaceType.getElement().lookupLocalElement( "call");
2297 if (ElementKind.of(callElement) == ElementKind.METHOD) { 2299 if (ElementKind.of(callElement) == ElementKind.METHOD) {
2298 node.setElement(callElement); 2300 node.setElement(callElement);
2299 type = typeAsMemberOf(callElement, interfaceType); 2301 type = typeAsMemberOf(callElement, interfaceType);
2300 } 2302 }
2301 } 2303 }
2302 break; 2304 break;
2303 } 2305 }
2304 checkDeprecated(target, element); 2306 checkDeprecated(target, element);
2305 return checkInvocation(node, target, name, type); 2307 Type returnType = checkInvocation(node, target, name, type);
2308 returnType = ExternalTypeAnalyzers.resolve(types, node, element, returnTyp e);
2309 return returnType;
2306 } 2310 }
2307 2311
2308 /** 2312 /**
2309 * Report warning if given {@link Element} is deprecated. 2313 * Report warning if given {@link Element} is deprecated.
2310 */ 2314 */
2311 private void checkDeprecated(HasSourceInfo nameNode, Element element) { 2315 private void checkDeprecated(HasSourceInfo nameNode, Element element) {
2312 if (element != null && element.getMetadata().isDeprecated()) { 2316 if (element != null && element.getMetadata().isDeprecated()) {
2313 onError(nameNode, TypeErrorCode.DEPRECATED_ELEMENT, element); 2317 onError(nameNode, TypeErrorCode.DEPRECATED_ELEMENT, element);
2314 } 2318 }
2315 } 2319 }
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 for (VariableElement v : parameters) { 2941 for (VariableElement v : parameters) {
2938 if (v.isNamed()) { 2942 if (v.isNamed()) {
2939 named.add(v); 2943 named.add(v);
2940 } 2944 }
2941 } 2945 }
2942 return named; 2946 return named;
2943 } 2947 }
2944 } 2948 }
2945 } 2949 }
2946 } 2950 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698