Skip to content

Commit

Permalink
Stop reporting CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER and …
Browse files Browse the repository at this point in the history
…CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER.

These errors were removed from the spec.
See also #33235

R=brianwilkerson@google.com

Bug: #34331
Change-Id: Ibc675aa48165300ddac32a8d6ddef4d84d41952a
Reviewed-on: https://dart-review.googlesource.com/72903
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Sep 4, 2018
1 parent e0b1576 commit 48a1504
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 237 deletions.
2 changes: 0 additions & 2 deletions pkg/analyzer/lib/error/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,8 @@ const List<ErrorCode> errorCodeValues = const [
StaticWarningCode.CASE_BLOCK_NOT_TERMINATED,
StaticWarningCode.CAST_TO_NON_TYPE,
StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER,
StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER,
StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER2,
StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER,
StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER,
StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER,
StaticWarningCode.CONST_WITH_ABSTRACT_CLASS,
Expand Down
31 changes: 0 additions & 31 deletions pkg/analyzer/lib/src/error/codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3562,21 +3562,6 @@ class StaticWarningCode extends ErrorCode {
"'{0}' must have a method body because '{1}' isn't abstract.",
correction: "Try making '{1}' abstract, or adding a body to '{0}'.");

/**
* 7.2 Getters: It is a static warning if a class <i>C</i> declares an
* instance getter named <i>v</i> and an accessible static member named
* <i>v</i> or <i>v=</i> is declared in a superclass of <i>C</i>.
*
* Parameters:
* 0: the name of the super class declaring a static member
*/
static const StaticWarningCode
CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER =
const StaticWarningCode(
'CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER',
"Superclass '{0}' declares static member with the same name.",
correction: "Try renaming either the getter or the static member.");

/**
* 7.1 Instance Methods: It is a static warning if a class <i>C</i> declares
* an instance method named <i>n</i> and has a setter named <i>n=</i>.
Expand All @@ -3599,22 +3584,6 @@ class StaticWarningCode extends ErrorCode {
"but also has an instance method in the same class.",
correction: "Try renaming either the method or the setter.");

/**
* 7.3 Setters: It is a static warning if a class <i>C</i> declares an
* instance setter named <i>v=</i> and an accessible static member named
* <i>v=</i> or <i>v</i> is declared in a superclass of <i>C</i>.
*
* Parameters:
* 0: the name of the super class declaring a static member
*/
static const StaticWarningCode
CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER =
const StaticWarningCode(
'CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER',
"Superclass '{0}' declares a static member with the same name.",
correction:
"Try renaming either the setter or the inherited member.");

/**
* 7.2 Getters: It is a static warning if a class declares a static getter
* named <i>v</i> and also has a non-static setter named <i>v=</i>.
Expand Down
67 changes: 0 additions & 67 deletions pkg/analyzer/lib/src/generated/error_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
_checkForInconsistentMethodInheritance();
_checkForRecursiveInterfaceInheritance(_enclosingClass);
_checkForConflictingGetterAndMethod();
_checkForConflictingInstanceGetterAndSuperclassMember();
_checkImplementsSuperClass(implementsClause);
_checkForMixinHasNoConstructors(node);
_checkMixinInference(node, withClause);
Expand Down Expand Up @@ -2488,71 +2487,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
}

/**
* Verify that the superclass of the [_enclosingClass] does not declare
* accessible static members with the same name as the instance
* getters/setters declared in [_enclosingClass].
*
* See [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER], and
* [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER].
*/
void _checkForConflictingInstanceGetterAndSuperclassMember() {
if (_enclosingClass == null) {
return;
}
InterfaceType enclosingType = _enclosingClass.type;
// check every accessor
for (PropertyAccessorElement accessor in _enclosingClass.accessors) {
// we analyze instance accessors here
if (accessor.isStatic) {
continue;
}
// prepare accessor properties
String name = accessor.displayName;
bool getter = accessor.isGetter;
// if non-final variable, ignore setter - we already reported problem for
// getter
if (accessor.isSetter && accessor.isSynthetic) {
continue;
}
// try to find super element
ExecutableElement superElement;
superElement =
enclosingType.lookUpGetterInSuperclass(name, _currentLibrary);
if (superElement == null) {
superElement =
enclosingType.lookUpSetterInSuperclass(name, _currentLibrary);
}
if (superElement == null) {
superElement =
enclosingType.lookUpMethodInSuperclass(name, _currentLibrary);
}
if (superElement == null) {
continue;
}
// OK, not static
if (!superElement.isStatic) {
continue;
}
// prepare "super" type to report its name
ClassElement superElementClass =
superElement.enclosingElement as ClassElement;
InterfaceType superElementType = superElementClass.type;

if (getter) {
_errorReporter.reportErrorForElement(
StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
accessor,
[superElementType.displayName]);
} else {
_errorReporter.reportErrorForElement(
StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER,
accessor,
[superElementType.displayName]);
}
}
}

/**
* Verify that the enclosing class does not have a setter with the same name
* as the given instance method declaration.
Expand Down Expand Up @@ -5960,7 +5894,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
// _checkForInconsistentMethodInheritance();
// _checkForRecursiveInterfaceInheritance(_enclosingClass);
// _checkForConflictingGetterAndMethod();
// _checkForConflictingInstanceGetterAndSuperclassMember();
// _checkImplementsSuperClass(implementsClause);
// _checkForMixinHasNoConstructors(node);
// _checkMixinInference(node, onClause);
Expand Down
8 changes: 2 additions & 6 deletions pkg/analyzer/test/generated/all_the_rest_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,7 @@ class ErrorReporterTest extends EngineTestCase {
GatheringErrorListener listener = new GatheringErrorListener();
ErrorReporter reporter = new ErrorReporter(listener, element.source);
reporter.reportErrorForElement(
StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
element,
['A']);
StaticWarningCode.CAST_TO_NON_TYPE, element, ['A']);
AnalysisError error = listener.errors[0];
expect(error.offset, element.nameOffset);
}
Expand All @@ -710,9 +708,7 @@ class ErrorReporterTest extends EngineTestCase {
new NonExistingSource(
'/test.dart', path.toUri('/test.dart'), UriKind.FILE_URI));
reporter.reportErrorForElement(
StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
element,
['A']);
StaticWarningCode.CAST_TO_NON_TYPE, element, ['A']);
AnalysisError error = listener.errors[0];
expect(error.offset, element.nameOffset);
}
Expand Down
13 changes: 0 additions & 13 deletions pkg/analyzer/test/generated/non_error_resolver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1248,19 +1248,6 @@ set x(_) {}
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_instance() async {
Source source = addSource(r'''
class A {
get v => 0;
}
class B extends A {
get v => 1;
}''');
await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}

test_conflictingStaticGetterAndInstanceSetter_thisClass() async {
Source source = addSource(r'''
class A {
Expand Down
113 changes: 0 additions & 113 deletions pkg/analyzer/test/generated/static_warning_code_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -982,105 +982,6 @@ class A implements I {
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter() async {
Source source = addSource(r'''
class A {
static set v(x) {}
}
class B extends A {
var v;
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_getter() async {
Source source = addSource(r'''
class A {
static get v => 0;
}
class B extends A {
get v => 0;
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_method() async {
Source source = addSource(r'''
class A {
static v() {}
}
class B extends A {
get v => 0;
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_setter() async {
Source source = addSource(r'''
class A {
static set v(x) {}
}
class B extends A {
get v => 0;
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_declGetter_indirect() async {
Source source = addSource(r'''
class A {
static int v;
}
class B extends A {}
class C extends B {
get v => 0;
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_declGetter_mixin() async {
Source source = addSource(r'''
class M {
static int v;
}
class B extends Object with M {
get v => 0;
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingInstanceGetterAndSuperclassMember_direct_field() async {
Source source = addSource(r'''
class A {
static int v;
}
class B extends A {
get v => 0;
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingInstanceMethodSetter2() async {
Source source = addSource(r'''
class A {
Expand Down Expand Up @@ -1133,20 +1034,6 @@ class B extends A {
verify([source]);
}

test_conflictingInstanceSetterAndSuperclassMember() async {
Source source = addSource(r'''
class A {
static int v;
}
class B extends A {
set v(x) {}
}''');
await computeAnalysisResult(source);
assertErrors(source,
[StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}

test_conflictingStaticGetterAndInstanceSetter_mixin() async {
Source source = addSource(r'''
class A {
Expand Down
12 changes: 12 additions & 0 deletions tests/co19_2/co19_2-analyzer.status
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Language/Classes/Abstract_Instance_Members/same_name_static_method_in_superclass
Language/Classes/Abstract_Instance_Members/same_name_static_method_in_superclass_t05: MissingCompileTimeError # Issue 33995
Language/Classes/Abstract_Instance_Members/same_name_static_method_in_superclass_t06: MissingCompileTimeError # Issue 33995
Language/Classes/Constructors/Generative_Constructors/final_variables_t01: CompileTimeError # co19 issue 155
Language/Classes/Getters/instance_getter_t01: MissingCompileTimeError # Legal, see #33235
Language/Classes/Getters/instance_getter_t02: MissingCompileTimeError # Legal, see #33235
Language/Classes/Getters/instance_getter_t03: MissingCompileTimeError # Legal, see #33235
Language/Classes/Getters/instance_getter_t04: MissingCompileTimeError # Legal, see #33235
Language/Classes/Getters/instance_getter_t05: MissingCompileTimeError # Legal, see #33235
Language/Classes/Getters/instance_getter_t06: MissingCompileTimeError # Legal, see #33235
Language/Classes/Getters/type_object_t01: CompileTimeError # Issue 33995
Language/Classes/Getters/type_object_t02: CompileTimeError # Issue 33995
Language/Classes/Instance_Methods/Operators/return_type_t01: CompileTimeError # co19 issue 156
Expand All @@ -26,6 +32,12 @@ Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t05: Mis
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t06: MissingCompileTimeError # Issue 27476
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t07: MissingCompileTimeError # Issue 27476
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t09: MissingCompileTimeError # Issue 27476
Language/Classes/Setters/instance_setter_t01: MissingCompileTimeError # Legal, see #33235
Language/Classes/Setters/instance_setter_t02: MissingCompileTimeError # Legal, see #33235
Language/Classes/Setters/instance_setter_t03: MissingCompileTimeError # Legal, see #33235
Language/Classes/Setters/instance_setter_t04: MissingCompileTimeError # Legal, see #33235
Language/Classes/Setters/instance_setter_t05: MissingCompileTimeError # Legal, see #33235
Language/Classes/Setters/instance_setter_t06: MissingCompileTimeError # Legal, see #33235
Language/Classes/Setters/return_type_not_void_t01: CompileTimeError # co19 issue 153
Language/Classes/Setters/same_name_getter_different_type_t01: CompileTimeError # co19 issue 154
Language/Classes/Setters/syntax_t04: CompileTimeError # co19 issue 153
Expand Down
2 changes: 0 additions & 2 deletions tests/language_2/language_2_analyzer.status
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ accessor_conflict_import_test: CompileTimeError # Issue 25626
additional_interface_adds_optional_args_test: CompileTimeError # Issue #30568
built_in_identifier_prefix_test: CompileTimeError
cascaded_forwarding_stubs_test: CompileTimeError
check_member_static_test/01: CompileTimeError
config_import_corelib_test: CompileTimeError
config_import_corelib_test: StaticWarning, OK
conflicting_generic_interfaces_hierarchy_loop_infinite_test: Skip # Crashes or times out
Expand Down Expand Up @@ -102,7 +101,6 @@ nested_generic_closure_test: CompileTimeError
no_main_test/01: Fail # Issue 20030
no_main_test/01: MissingStaticWarning # Issue 28823
no_such_constructor2_test: StaticWarning
override_field_test/02: CompileTimeError
override_inheritance_field_test/42: CompileTimeError
parser_quirks_test: CompileTimeError
part_of_multiple_libs_test/01: MissingCompileTimeError # Issue 33227
Expand Down
4 changes: 1 addition & 3 deletions tests/language_2/language_2_dartdevc.status
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ built_in_identifier_type_annotation_test/dynamic-funret: RuntimeError # Issue 28
built_in_identifier_type_annotation_test/dynamic-list: RuntimeError # Issue 28816
cascaded_forwarding_stubs_generic_test: RuntimeError
cascaded_forwarding_stubs_test: CompileTimeError
check_member_static_test/01: CompileTimeError
conflicting_generic_interfaces_hierarchy_loop_infinite_test: Skip # Crashes or times out
conflicting_generic_interfaces_simple_test: MissingCompileTimeError
const_cast2_test/01: CompileTimeError
Expand Down Expand Up @@ -130,7 +129,6 @@ mixin_type_parameter_inference_test/09: RuntimeError
mock_writable_final_private_field_test: CompileTimeError # Issue 30848
multiple_interface_inheritance_test: CompileTimeError # Issue 30552
nested_generic_closure_test: CompileTimeError
override_field_test/02: CompileTimeError
override_inheritance_field_test/42: CompileTimeError
part_of_multiple_libs_test/01: MissingCompileTimeError
part_refers_to_core_library_test/01: Crash
Expand Down Expand Up @@ -460,8 +458,8 @@ generic_instanceof2_test: RuntimeError # Issue 29920; ReferenceError: FooOfK$Str
generic_is_check_test: RuntimeError # Issue 29920; Expect.isTrue(false) fails.
generic_tearoff_test: CompileTimeError
guess_cid_test: CompileTimeError, OK # Error if web int literal cannot be represented exactly, see http://dartbug.com/33351
identical_closure2_test: CompileTimeError, OK # Error if web int literal cannot be represented exactly, see http://dartbug.com/33351
identical_closure2_test: RuntimeError # Issue 29920; Expect.isFalse(true) fails.
identical_closure2_test: CompileTimeError, OK # Error if web int literal cannot be represented exactly, see http://dartbug.com/33351
infinite_switch_label_test: RuntimeError # Issue 29920; NoSuchMethodError: method not found: '<Unexpected Null Value>'
infinity_test: RuntimeError # Issue 29920; Expect.isFalse(true) fails.
instance_creation_in_function_annotation_test: RuntimeError # Issue 29920; UnimplementedError: JsClosureMirror.function unimplemented
Expand Down

0 comments on commit 48a1504

Please sign in to comment.