@@ -2009,31 +2009,55 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
2009
2009
for (MethodElement method in enclosingClass.methods) {
2010
2010
String name = method.name;
2011
2011
2012
- // find inherited property accessor
2013
- var inherited = _inheritanceManager.getInherited2 (
2012
+ // find inherited property accessors
2013
+ final getter = _inheritanceManager.getInherited2 (
2014
2014
enclosingClass, Name (libraryUri, name));
2015
- inherited ?? = _inheritanceManager.getInherited2 (
2015
+ final setter = _inheritanceManager.getInherited2 (
2016
2016
enclosingClass, Name (libraryUri, '$name =' ));
2017
2017
2018
- if (method.isStatic && inherited != null ) {
2019
- errorReporter.reportErrorForElement (
2020
- CompileTimeErrorCode .CONFLICTING_STATIC_AND_INSTANCE , method, [
2021
- enclosingClass.displayName,
2022
- name,
2023
- inherited.enclosingElement.displayName,
2024
- ]);
2025
- } else if (inherited is PropertyAccessorElement ) {
2026
- // Extension type methods redeclare getters with the same name.
2027
- if (enclosingClass is ExtensionTypeElement && inherited.isGetter) {
2018
+ if (method.isStatic) {
2019
+ void reportStaticConflict (ExecutableElement inherited) {
2020
+ errorReporter.reportErrorForElement (
2021
+ CompileTimeErrorCode .CONFLICTING_STATIC_AND_INSTANCE , method, [
2022
+ enclosingClass.displayName,
2023
+ name,
2024
+ inherited.enclosingElement.displayName,
2025
+ ]);
2026
+ }
2027
+
2028
+ if (getter != null ) {
2029
+ reportStaticConflict (getter);
2028
2030
continue ;
2029
2031
}
2032
+
2033
+ if (setter != null ) {
2034
+ reportStaticConflict (setter);
2035
+ continue ;
2036
+ }
2037
+ }
2038
+
2039
+ void reportFieldConflict (PropertyAccessorElement inherited) {
2030
2040
errorReporter.reportErrorForElement (
2031
2041
CompileTimeErrorCode .CONFLICTING_METHOD_AND_FIELD , method, [
2032
2042
enclosingClass.displayName,
2033
2043
name,
2034
2044
inherited.enclosingElement.displayName
2035
2045
]);
2036
2046
}
2047
+
2048
+ if (getter is PropertyAccessorElement ) {
2049
+ if (enclosingClass is ExtensionTypeElement ) {
2050
+ // Extension type methods redeclare getters with the same name.
2051
+ } else {
2052
+ reportFieldConflict (getter);
2053
+ continue ;
2054
+ }
2055
+ }
2056
+
2057
+ if (setter is PropertyAccessorElement ) {
2058
+ reportFieldConflict (setter);
2059
+ continue ;
2060
+ }
2037
2061
}
2038
2062
2039
2063
// getter declared in the enclosing class vs. inherited method
0 commit comments