OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, the Dart project authors. | 2 * Copyright (c) 2013, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 public Element getStaticElement() { | 230 public Element getStaticElement() { |
231 return null; | 231 return null; |
232 } | 232 } |
233 | 233 |
234 @Override | 234 @Override |
235 public void visitChildren(ASTVisitor<?> visitor) { | 235 public void visitChildren(ASTVisitor<?> visitor) { |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 /** | 239 /** |
| 240 * Checks if the given expression is the reference to the type, if it is then
the |
| 241 * {@link ClassElement} is returned, otherwise {@code null} is returned. |
| 242 * |
| 243 * @param expr the expression to evaluate |
| 244 * @return the {@link ClassElement} if the given expression is the reference t
o the type, and |
| 245 * {@code null} otherwise |
| 246 */ |
| 247 public static ClassElementImpl getTypeReference(Expression expr) { |
| 248 if (expr instanceof Identifier) { |
| 249 Identifier identifier = (Identifier) expr; |
| 250 if (identifier.getStaticElement() instanceof ClassElementImpl) { |
| 251 return (ClassElementImpl) identifier.getStaticElement(); |
| 252 } |
| 253 } |
| 254 return null; |
| 255 } |
| 256 |
| 257 /** |
240 * @return {@code true} if the given identifier is the return type of a constr
uctor declaration. | 258 * @return {@code true} if the given identifier is the return type of a constr
uctor declaration. |
241 */ | 259 */ |
242 private static boolean isConstructorReturnType(SimpleIdentifier node) { | 260 private static boolean isConstructorReturnType(SimpleIdentifier node) { |
243 ASTNode parent = node.getParent(); | 261 ASTNode parent = node.getParent(); |
244 if (parent instanceof ConstructorDeclaration) { | 262 if (parent instanceof ConstructorDeclaration) { |
245 ConstructorDeclaration constructor = (ConstructorDeclaration) parent; | 263 ConstructorDeclaration constructor = (ConstructorDeclaration) parent; |
246 return constructor.getReturnType() == node; | 264 return constructor.getReturnType() == node; |
247 } | 265 } |
248 return false; | 266 return false; |
249 } | 267 } |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 if (target instanceof SuperExpression && !isSuperInValidContext((SuperExpres
sion) target)) { | 948 if (target instanceof SuperExpression && !isSuperInValidContext((SuperExpres
sion) target)) { |
931 return null; | 949 return null; |
932 } | 950 } |
933 Element staticElement; | 951 Element staticElement; |
934 Element propagatedElement; | 952 Element propagatedElement; |
935 if (target == null) { | 953 if (target == null) { |
936 staticElement = resolveInvokedElement(methodName); | 954 staticElement = resolveInvokedElement(methodName); |
937 propagatedElement = null; | 955 propagatedElement = null; |
938 } else { | 956 } else { |
939 Type staticType = getStaticType(target); | 957 Type staticType = getStaticType(target); |
940 staticElement = resolveInvokedElement(target, staticType, methodName); | 958 // |
941 propagatedElement = resolveInvokedElement(target, getPropagatedType(target
), methodName); | 959 // If this method invocation is of the form 'C.m' where 'C' is a class, th
en we don't call |
| 960 // resolveInvokedElement(..) which walks up the class hierarchy, instead w
e just look for the |
| 961 // member in the type only. |
| 962 // |
| 963 ClassElementImpl typeReference = getTypeReference(target); |
| 964 if (typeReference != null) { |
| 965 staticElement = propagatedElement = resolveElement(typeReference, method
Name.getName()); |
| 966 } else { |
| 967 staticElement = resolveInvokedElement(target, staticType, methodName); |
| 968 propagatedElement = resolveInvokedElement(target, getPropagatedType(targ
et), methodName); |
| 969 } |
942 } | 970 } |
943 staticElement = convertSetterToGetter(staticElement); | 971 staticElement = convertSetterToGetter(staticElement); |
944 propagatedElement = convertSetterToGetter(propagatedElement); | 972 propagatedElement = convertSetterToGetter(propagatedElement); |
945 // | 973 // |
946 // Record the results. | 974 // Record the results. |
947 // | 975 // |
948 methodName.setStaticElement(staticElement); | 976 methodName.setStaticElement(staticElement); |
949 methodName.setPropagatedElement(propagatedElement); | 977 methodName.setPropagatedElement(propagatedElement); |
950 ArgumentList argumentList = node.getArgumentList(); | 978 ArgumentList argumentList = node.getArgumentList(); |
951 if (staticElement != null) { | 979 if (staticElement != null) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 element = setter; | 1190 element = setter; |
1163 } | 1191 } |
1164 } | 1192 } |
1165 } | 1193 } |
1166 // TODO(brianwilkerson) The prefix needs to be resolved to the element for
the import that | 1194 // TODO(brianwilkerson) The prefix needs to be resolved to the element for
the import that |
1167 // defines the prefix, not the prefix's element. | 1195 // defines the prefix, not the prefix's element. |
1168 identifier.setStaticElement(element); | 1196 identifier.setStaticElement(element); |
1169 // Validate annotation element. | 1197 // Validate annotation element. |
1170 if (node.getParent() instanceof Annotation) { | 1198 if (node.getParent() instanceof Annotation) { |
1171 Annotation annotation = (Annotation) node.getParent(); | 1199 Annotation annotation = (Annotation) node.getParent(); |
1172 resolveAnnotationElement(annotation, element, null); | 1200 resolveAnnotationElement(annotation); |
1173 return null; | 1201 return null; |
1174 } | 1202 } |
1175 return null; | 1203 return null; |
1176 } | 1204 } |
1177 | 1205 |
1178 // May be annotation, resolve invocation of "const" constructor. | 1206 // May be annotation, resolve invocation of "const" constructor. |
1179 if (node.getParent() instanceof Annotation) { | 1207 if (node.getParent() instanceof Annotation) { |
1180 Annotation annotation = (Annotation) node.getParent(); | 1208 Annotation annotation = (Annotation) node.getParent(); |
1181 resolveAnnotationElement(annotation, prefixElement, identifier); | 1209 resolveAnnotationElement(annotation); |
1182 } | 1210 } |
1183 | 1211 |
1184 // | 1212 // |
1185 // Otherwise, the prefix is really an expression that happens to be a simple
identifier and this | 1213 // Otherwise, the prefix is really an expression that happens to be a simple
identifier and this |
1186 // is really equivalent to a property access node. | 1214 // is really equivalent to a property access node. |
1187 // | 1215 // |
1188 resolvePropertyAccess(prefix, identifier); | 1216 resolvePropertyAccess(prefix, identifier); |
1189 return null; | 1217 return null; |
1190 } | 1218 } |
1191 | 1219 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 enclosingType, | 1359 enclosingType, |
1332 node.getName()), null); | 1360 node.getName()), null); |
1333 node.setAuxiliaryElements(auxiliaryElements); | 1361 node.setAuxiliaryElements(auxiliaryElements); |
1334 } | 1362 } |
1335 | 1363 |
1336 // | 1364 // |
1337 // Validate annotation element. | 1365 // Validate annotation element. |
1338 // | 1366 // |
1339 if (node.getParent() instanceof Annotation) { | 1367 if (node.getParent() instanceof Annotation) { |
1340 Annotation annotation = (Annotation) node.getParent(); | 1368 Annotation annotation = (Annotation) node.getParent(); |
1341 resolveAnnotationElement(annotation, element, null); | 1369 resolveAnnotationElement(annotation); |
1342 } | 1370 } |
1343 return null; | 1371 return null; |
1344 } | 1372 } |
1345 | 1373 |
1346 @Override | 1374 @Override |
1347 public Void visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 1375 public Void visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
1348 ClassElement enclosingClass = resolver.getEnclosingClass(); | 1376 ClassElement enclosingClass = resolver.getEnclosingClass(); |
1349 if (enclosingClass == null) { | 1377 if (enclosingClass == null) { |
1350 // TODO(brianwilkerson) Report this error. | 1378 // TODO(brianwilkerson) Report this error. |
1351 return null; | 1379 return null; |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2288 return; | 2316 return; |
2289 } | 2317 } |
2290 // resolve arguments to parameters | 2318 // resolve arguments to parameters |
2291 ParameterElement[] parameters = resolveArgumentsToParameters(true, argumentL
ist, constructor); | 2319 ParameterElement[] parameters = resolveArgumentsToParameters(true, argumentL
ist, constructor); |
2292 if (parameters != null) { | 2320 if (parameters != null) { |
2293 argumentList.setCorrespondingStaticParameters(parameters); | 2321 argumentList.setCorrespondingStaticParameters(parameters); |
2294 } | 2322 } |
2295 } | 2323 } |
2296 | 2324 |
2297 /** | 2325 /** |
2298 * Validates that the given {@link Element} is the constant variable; or resol
ves it as a | 2326 * Continues resolution of the given {@link Annotation}. |
2299 * constructor invocation. | |
2300 * | 2327 * |
2301 * @param annotation the {@link Annotation} to resolve | 2328 * @param annotation the {@link Annotation} to resolve |
2302 * @param element the current known {@link Element} of the annotation, or {@li
nk ClassElement} | |
2303 * @param nameNode the name of the invoked constructor, may be {@code null} if
unnamed constructor | |
2304 * or not a constructor invocation | |
2305 */ | 2329 */ |
2306 private void resolveAnnotationElement(Annotation annotation, Element element, | 2330 private void resolveAnnotationElement(Annotation annotation) { |
2307 SimpleIdentifier nameNode) { | 2331 SimpleIdentifier nameNode1; |
2308 // constant variable | 2332 SimpleIdentifier nameNode2; |
2309 if (element instanceof PropertyAccessorElement) { | 2333 { |
2310 PropertyAccessorElement accessorElement = (PropertyAccessorElement) elemen
t; | 2334 Identifier annName = annotation.getName(); |
2311 // accessor should be synthetic | 2335 if (annName instanceof PrefixedIdentifier) { |
2312 if (!accessorElement.isSynthetic()) { | 2336 PrefixedIdentifier prefixed = (PrefixedIdentifier) annName; |
2313 resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation
); | 2337 nameNode1 = prefixed.getPrefix(); |
| 2338 nameNode2 = prefixed.getIdentifier(); |
| 2339 } else { |
| 2340 nameNode1 = (SimpleIdentifier) annName; |
| 2341 nameNode2 = null; |
| 2342 } |
| 2343 } |
| 2344 SimpleIdentifier nameNode3 = annotation.getConstructorName(); |
| 2345 ConstructorElement constructor = null; |
| 2346 // |
| 2347 // CONST or Class(args) |
| 2348 // |
| 2349 if (nameNode1 != null && nameNode2 == null && nameNode3 == null) { |
| 2350 Element element1 = nameNode1.getStaticElement(); |
| 2351 // CONST |
| 2352 if (element1 instanceof PropertyAccessorElement) { |
| 2353 resolveAnnotationElementGetter(annotation, (PropertyAccessorElement) ele
ment1); |
2314 return; | 2354 return; |
2315 } | 2355 } |
2316 // variable should be constant | 2356 // Class(args) |
2317 VariableElement variableElement = accessorElement.getVariable(); | 2357 if (element1 instanceof ClassElement) { |
2318 if (!variableElement.isConst()) { | 2358 ClassElement classElement = (ClassElement) element1; |
2319 resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation
); | 2359 constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(null
, definingLibrary); |
2320 } | 2360 } |
2321 // OK | 2361 } |
| 2362 // |
| 2363 // prefix.CONST or prefix.Class() or Class.CONST or Class.constructor(args) |
| 2364 // |
| 2365 if (nameNode1 != null && nameNode2 != null && nameNode3 == null) { |
| 2366 Element element1 = nameNode1.getStaticElement(); |
| 2367 Element element2 = nameNode2.getStaticElement(); |
| 2368 // Class.CONST - not resolved yet |
| 2369 if (element1 instanceof ClassElement) { |
| 2370 ClassElement classElement = (ClassElement) element1; |
| 2371 element2 = classElement.lookUpGetter(nameNode2.getName(), definingLibrar
y); |
| 2372 } |
| 2373 // prefix.CONST or Class.CONST |
| 2374 if (element2 instanceof PropertyAccessorElement) { |
| 2375 nameNode2.setStaticElement(element2); |
| 2376 annotation.setElement(element2); |
| 2377 resolveAnnotationElementGetter(annotation, (PropertyAccessorElement) ele
ment2); |
| 2378 return; |
| 2379 } |
| 2380 // prefix.Class() |
| 2381 if (element2 instanceof ClassElement) { |
| 2382 ClassElement classElement = (ClassElement) element2; |
| 2383 constructor = classElement.getUnnamedConstructor(); |
| 2384 } |
| 2385 // Class.constructor(args) |
| 2386 if (element1 instanceof ClassElement) { |
| 2387 ClassElement classElement = (ClassElement) element1; |
| 2388 constructor = new InterfaceTypeImpl(classElement).lookUpConstructor( |
| 2389 nameNode2.getName(), |
| 2390 definingLibrary); |
| 2391 nameNode2.setStaticElement(constructor); |
| 2392 } |
| 2393 } |
| 2394 // |
| 2395 // prefix.Class.CONST or prefix.Class.constructor(args) |
| 2396 // |
| 2397 if (nameNode1 != null && nameNode2 != null && nameNode3 != null) { |
| 2398 Element element2 = nameNode2.getStaticElement(); |
| 2399 // element2 should be ClassElement |
| 2400 if (element2 instanceof ClassElement) { |
| 2401 ClassElement classElement = (ClassElement) element2; |
| 2402 String name3 = nameNode3.getName(); |
| 2403 // prefix.Class.CONST |
| 2404 PropertyAccessorElement getter = classElement.lookUpGetter(name3, defini
ngLibrary); |
| 2405 if (getter != null) { |
| 2406 nameNode3.setStaticElement(getter); |
| 2407 annotation.setElement(element2); |
| 2408 resolveAnnotationElementGetter(annotation, getter); |
| 2409 return; |
| 2410 } |
| 2411 // prefix.Class.constructor(args) |
| 2412 constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(name
3, definingLibrary); |
| 2413 nameNode3.setStaticElement(constructor); |
| 2414 } |
| 2415 } |
| 2416 // we need constructor |
| 2417 if (constructor == null) { |
| 2418 resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation); |
2322 return; | 2419 return; |
2323 } | 2420 } |
2324 // const constructor invocation | 2421 // record element |
2325 if (element instanceof ClassElement) { | 2422 annotation.setElement(constructor); |
2326 // prepare constructor name | 2423 // resolve arguments |
2327 if (nameNode == null) { | 2424 resolveAnnotationConstructorInvocationArguments(annotation, constructor); |
2328 nameNode = annotation.getConstructorName(); | 2425 } |
2329 } | 2426 |
2330 String name = nameNode != null ? nameNode.getName() : null; | 2427 private void resolveAnnotationElementGetter(Annotation annotation, |
2331 // look up ConstructorElement | 2428 PropertyAccessorElement accessorElement) { |
2332 ConstructorElement constructor; | 2429 // accessor should be synthetic |
2333 { | 2430 if (!accessorElement.isSynthetic()) { |
2334 InterfaceType interfaceType = new InterfaceTypeImpl((ClassElement) eleme
nt); | 2431 resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation); |
2335 constructor = interfaceType.lookUpConstructor(name, definingLibrary); | |
2336 } | |
2337 // not a constructor | |
2338 if (constructor == null) { | |
2339 resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation
); | |
2340 return; | |
2341 } | |
2342 // record element | |
2343 annotation.setElement(constructor); | |
2344 if (nameNode != null) { | |
2345 nameNode.setStaticElement(constructor); | |
2346 } | |
2347 // resolve arguments | |
2348 resolveAnnotationConstructorInvocationArguments(annotation, constructor); | |
2349 // OK | |
2350 return; | 2432 return; |
2351 } | 2433 } |
2352 // something unknown | 2434 // variable should be constant |
2353 if (element != null) { | 2435 VariableElement variableElement = accessorElement.getVariable(); |
| 2436 if (!variableElement.isConst()) { |
2354 resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation); | 2437 resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation); |
2355 } | 2438 } |
| 2439 // OK |
| 2440 return; |
2356 } | 2441 } |
2357 | 2442 |
2358 /** | 2443 /** |
2359 * Given a list of arguments and the element that will be invoked using those
argument, compute | 2444 * Given a list of arguments and the element that will be invoked using those
argument, compute |
2360 * the list of parameters that correspond to the list of arguments. Return the
parameters that | 2445 * the list of parameters that correspond to the list of arguments. Return the
parameters that |
2361 * correspond to the arguments, or {@code null} if no correspondence could be
computed. | 2446 * correspond to the arguments, or {@code null} if no correspondence could be
computed. |
2362 * | 2447 * |
2363 * @param reportError if {@code true} then compile-time error should be report
ed; if {@code false} | 2448 * @param reportError if {@code true} then compile-time error should be report
ed; if {@code false} |
2364 * then compile-time warning | 2449 * then compile-time warning |
2365 * @param argumentList the list of arguments being passed to the element | 2450 * @param argumentList the list of arguments being passed to the element |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2477 for (SimpleIdentifier name : names) { | 2562 for (SimpleIdentifier name : names) { |
2478 Element element = namespace.get(name.getName()); | 2563 Element element = namespace.get(name.getName()); |
2479 if (element != null) { | 2564 if (element != null) { |
2480 name.setStaticElement(element); | 2565 name.setStaticElement(element); |
2481 } | 2566 } |
2482 } | 2567 } |
2483 } | 2568 } |
2484 } | 2569 } |
2485 | 2570 |
2486 /** | 2571 /** |
| 2572 * Given an invocation of the form 'C.x()' where 'C' is a class, find and retu
rn the element 'x' |
| 2573 * in 'C'. |
| 2574 * |
| 2575 * @param classElement the class element |
| 2576 * @param memberName the member name |
| 2577 */ |
| 2578 private Element resolveElement(ClassElementImpl classElement, String memberNam
e) { |
| 2579 Element element = null; |
| 2580 String methodNameStr = memberName; |
| 2581 element = classElement.getMethod(methodNameStr); |
| 2582 if (element == null) { |
| 2583 element = classElement.getSetter(memberName); |
| 2584 if (element == null) { |
| 2585 element = classElement.getGetter(memberName); |
| 2586 } |
| 2587 } |
| 2588 if (element != null && element.isAccessibleIn(definingLibrary)) { |
| 2589 return element; |
| 2590 } |
| 2591 return null; |
| 2592 } |
| 2593 |
| 2594 /** |
2487 * Given an invocation of the form 'e.m(a1, ..., an)', resolve 'e.m' to the el
ement being invoked. | 2595 * Given an invocation of the form 'e.m(a1, ..., an)', resolve 'e.m' to the el
ement being invoked. |
2488 * If the returned element is a method, then the method will be invoked. If th
e returned element | 2596 * If the returned element is a method, then the method will be invoked. If th
e returned element |
2489 * is a getter, the getter will be invoked without arguments and the result of
that invocation | 2597 * is a getter, the getter will be invoked without arguments and the result of
that invocation |
2490 * will then be invoked with the arguments. | 2598 * will then be invoked with the arguments. |
2491 * | 2599 * |
2492 * @param target the target of the invocation ('e') | 2600 * @param target the target of the invocation ('e') |
2493 * @param targetType the type of the target | 2601 * @param targetType the type of the target |
2494 * @param methodName the name of the method being invoked ('m') | 2602 * @param methodName the name of the method being invoked ('m') |
2495 * @return the element being invoked | 2603 * @return the element being invoked |
2496 */ | 2604 */ |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 memberElement = lookUpGetter(target, targetType, propertyName.getName()); | 2689 memberElement = lookUpGetter(target, targetType, propertyName.getName()); |
2582 } | 2690 } |
2583 if (memberElement == null) { | 2691 if (memberElement == null) { |
2584 memberElement = lookUpMethod(target, targetType, propertyName.getName()); | 2692 memberElement = lookUpMethod(target, targetType, propertyName.getName()); |
2585 } | 2693 } |
2586 return memberElement; | 2694 return memberElement; |
2587 } | 2695 } |
2588 | 2696 |
2589 private void resolvePropertyAccess(Expression target, SimpleIdentifier propert
yName) { | 2697 private void resolvePropertyAccess(Expression target, SimpleIdentifier propert
yName) { |
2590 Type staticType = getStaticType(target); | 2698 Type staticType = getStaticType(target); |
2591 ExecutableElement staticElement = resolveProperty(target, staticType, proper
tyName); | 2699 Type propagatedType = getPropagatedType(target); |
| 2700 |
| 2701 Element staticElement = null; |
| 2702 Element propagatedElement = null; |
| 2703 |
| 2704 // |
| 2705 // If this property access is of the form 'C.m' where 'C' is a class, then w
e don't call |
| 2706 // resolveProperty(..) which walks up the class hierarchy, instead we just l
ook for the |
| 2707 // member in the type only. |
| 2708 // |
| 2709 ClassElementImpl typeReference = getTypeReference(target); |
| 2710 if (typeReference != null) { |
| 2711 staticElement = propagatedElement = resolveElement(typeReference, property
Name.getName()); |
| 2712 } else { |
| 2713 staticElement = resolveProperty(target, staticType, propertyName); |
| 2714 propagatedElement = resolveProperty(target, propagatedType, propertyName); |
| 2715 } |
2592 | 2716 |
2593 // May be part of annotation, record property element only if exists. | 2717 // May be part of annotation, record property element only if exists. |
2594 // Error was already reported in validateAnnotationElement(). | 2718 // Error was already reported in validateAnnotationElement(). |
2595 if (target.getParent().getParent() instanceof Annotation) { | 2719 if (target.getParent().getParent() instanceof Annotation) { |
2596 if (staticElement != null) { | 2720 if (staticElement != null) { |
2597 propertyName.setStaticElement(staticElement); | 2721 propertyName.setStaticElement(staticElement); |
2598 } | 2722 } |
2599 return; | 2723 return; |
2600 } | 2724 } |
| 2725 |
2601 propertyName.setStaticElement(staticElement); | 2726 propertyName.setStaticElement(staticElement); |
2602 | |
2603 Type propagatedType = getPropagatedType(target); | |
2604 ExecutableElement propagatedElement = resolveProperty(target, propagatedType
, propertyName); | |
2605 propertyName.setPropagatedElement(propagatedElement); | 2727 propertyName.setPropagatedElement(propagatedElement); |
2606 | 2728 |
2607 boolean shouldReportMissingMember_static = shouldReportMissingMember(staticT
ype, staticElement) | 2729 boolean shouldReportMissingMember_static = shouldReportMissingMember(staticT
ype, staticElement) |
2608 && (strictMode || shouldReportMissingMember(propagatedType, propagatedEl
ement)); | 2730 && (strictMode || shouldReportMissingMember(propagatedType, propagatedEl
ement)); |
2609 boolean shouldReportMissingMember_propagated = !shouldReportMissingMember_st
atic && enableHints | 2731 boolean shouldReportMissingMember_propagated = !shouldReportMissingMember_st
atic && enableHints |
2610 ? shouldReportMissingMember(propagatedType, propagatedElement) : false; | 2732 ? shouldReportMissingMember(propagatedType, propagatedElement) : false; |
2611 | 2733 |
2612 // If we are about to generate the hint (propagated version of this warning)
, then check | 2734 // If we are about to generate the hint (propagated version of this warning)
, then check |
2613 // that the member is not in a subtype of the propagated type. | 2735 // that the member is not in a subtype of the propagated type. |
2614 if (shouldReportMissingMember_propagated) { | 2736 if (shouldReportMissingMember_propagated) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2785 } | 2907 } |
2786 | 2908 |
2787 /** | 2909 /** |
2788 * Return {@code true} if we should report an error as a result of looking up
a member in the | 2910 * Return {@code true} if we should report an error as a result of looking up
a member in the |
2789 * given type and not finding any member. | 2911 * given type and not finding any member. |
2790 * | 2912 * |
2791 * @param type the type in which we attempted to perform the look-up | 2913 * @param type the type in which we attempted to perform the look-up |
2792 * @param member the result of the look-up | 2914 * @param member the result of the look-up |
2793 * @return {@code true} if we should report an error | 2915 * @return {@code true} if we should report an error |
2794 */ | 2916 */ |
2795 private boolean shouldReportMissingMember(Type type, ExecutableElement member)
{ | 2917 private boolean shouldReportMissingMember(Type type, Element member) { |
2796 if (member != null || type == null || type.isDynamic() || type.isBottom()) { | 2918 if (member != null || type == null || type.isDynamic() || type.isBottom()) { |
2797 return false; | 2919 return false; |
2798 } | 2920 } |
2799 return true; | 2921 return true; |
2800 } | 2922 } |
2801 } | 2923 } |
OLD | NEW |