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 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 if (node.isGetter()) { | 807 if (node.isGetter()) { |
808 checkForConflictingStaticGetterAndInstanceSetter(node); | 808 checkForConflictingStaticGetterAndInstanceSetter(node); |
809 } else if (node.isSetter()) { | 809 } else if (node.isSetter()) { |
810 checkForWrongNumberOfParametersForSetter(node.getName(), node.getParamet ers()); | 810 checkForWrongNumberOfParametersForSetter(node.getName(), node.getParamet ers()); |
811 checkForNonVoidReturnTypeForSetter(node.getReturnType()); | 811 checkForNonVoidReturnTypeForSetter(node.getReturnType()); |
812 checkForConflictingStaticSetterAndInstanceMember(node); | 812 checkForConflictingStaticSetterAndInstanceMember(node); |
813 } else if (node.isOperator()) { | 813 } else if (node.isOperator()) { |
814 checkForOptionalParameterInOperator(node); | 814 checkForOptionalParameterInOperator(node); |
815 checkForWrongNumberOfParametersForOperator(node); | 815 checkForWrongNumberOfParametersForOperator(node); |
816 checkForNonVoidReturnTypeForOperator(node); | 816 checkForNonVoidReturnTypeForOperator(node); |
817 } else { | |
818 checkForConflictingInstanceMethodSetter(node); | |
817 } | 819 } |
818 checkForConcreteClassWithAbstractMember(node); | 820 checkForConcreteClassWithAbstractMember(node); |
819 checkForAllInvalidOverrideErrorCodes(node); | 821 checkForAllInvalidOverrideErrorCodes(node); |
820 return super.visitMethodDeclaration(node); | 822 return super.visitMethodDeclaration(node); |
821 } finally { | 823 } finally { |
822 enclosingFunction = previousFunction; | 824 enclosingFunction = previousFunction; |
823 isInStaticMethod = false; | 825 isInStaticMethod = false; |
824 } | 826 } |
825 } | 827 } |
826 | 828 |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2255 } else { | 2257 } else { |
2256 errorReporter.reportError( | 2258 errorReporter.reportError( |
2257 StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER, | 2259 StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER, |
2258 nameNode, | 2260 nameNode, |
2259 superElementType.getDisplayName()); | 2261 superElementType.getDisplayName()); |
2260 } | 2262 } |
2261 return true; | 2263 return true; |
2262 } | 2264 } |
2263 | 2265 |
2264 /** | 2266 /** |
2267 * This verifies that the enclosing class does not have a setter with the same name as the passed | |
2268 * instance method declaration. | |
2269 * | |
2270 * @param node the method declaration to evaluate | |
2271 * @return {@code true} if and only if an error code is generated on the passe d node | |
2272 * @see StaticWarningCode#CONFLICTING_INSTANCE_METHOD_SETTER | |
2273 */ | |
2274 private boolean checkForConflictingInstanceMethodSetter(MethodDeclaration node ) { | |
2275 if (node.isStatic()) { | |
2276 return false; | |
2277 } | |
2278 // prepare name | |
2279 SimpleIdentifier nameNode = node.getName(); | |
2280 if (nameNode == null) { | |
2281 return false; | |
2282 } | |
2283 String name = nameNode.getName(); | |
2284 // prepare enclosing type | |
2285 if (enclosingClass == null) { | |
2286 return false; | |
2287 } | |
2288 InterfaceType enclosingType = enclosingClass.getType(); | |
2289 // try to find setter | |
2290 ExecutableElement setter = enclosingType.lookUpSetter(name, currentLibrary); | |
Brian Wilkerson
2013/11/02 15:19:38
Should this be using the InheritanceManager to do
scheglov
2013/11/02 20:32:00
Yes, we need to use InheritanceManager.
Fixed.
| |
2291 if (setter == null) { | |
2292 return false; | |
2293 } | |
2294 // already reported as INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC | |
2295 if (setter.isStatic()) { | |
2296 return false; | |
2297 } | |
2298 // report problem | |
2299 errorReporter.reportError( | |
2300 StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER, | |
2301 nameNode, | |
2302 enclosingType.getDisplayName(), | |
2303 name); | |
2304 return true; | |
2305 } | |
2306 | |
2307 /** | |
2265 * This verifies that the enclosing class does not have an instance member wit h the same name as | 2308 * This verifies that the enclosing class does not have an instance member wit h the same name as |
2266 * the passed static getter method declaration. | 2309 * the passed static getter method declaration. |
2267 * | 2310 * |
2268 * @param node the method declaration to evaluate | 2311 * @param node the method declaration to evaluate |
2269 * @return {@code true} if and only if an error code is generated on the passe d node | 2312 * @return {@code true} if and only if an error code is generated on the passe d node |
2270 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER | 2313 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER |
2271 */ | 2314 */ |
2272 private boolean checkForConflictingStaticGetterAndInstanceSetter(MethodDeclara tion node) { | 2315 private boolean checkForConflictingStaticGetterAndInstanceSetter(MethodDeclara tion node) { |
2273 if (!node.isStatic()) { | 2316 if (!node.isStatic()) { |
2274 return false; | 2317 return false; |
(...skipping 3132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5407 if (superClassElt != null) { | 5450 if (superClassElt != null) { |
5408 return memberHasConcreteMethodImplementationInSuperclassChain( | 5451 return memberHasConcreteMethodImplementationInSuperclassChain( |
5409 superClassElt, | 5452 superClassElt, |
5410 methodName, | 5453 methodName, |
5411 superclassChain); | 5454 superclassChain); |
5412 } | 5455 } |
5413 } | 5456 } |
5414 return false; | 5457 return false; |
5415 } | 5458 } |
5416 } | 5459 } |
OLD | NEW |