Sdk: IntelliJ Rename Field doesn't allow "shadowing" abstract getter

Created on 13 Mar 2017  路  8Comments  路  Source: dart-lang/sdk

If I need to implement a field "foo", I'm not allowed to do that by renaming an existing field; IntelliJ complains that this will shadow the field. Repro:

class Implements implements Defines {
  @override
  String bar;
}

abstract class Defines {
  String get foo;
}

Right click on "bar", choose "refactor->rename", rename to "foo".

Expected behaviour: it should always be allowed to "shadow" (implement) an abstract field.

The same bug applies to methods. It should always be allowed to "shadow" an abstract method.

P2 analyzer-refactoring area-intellij type-bug

All 8 comments

@scheglov I believe that this is being done by server. Is that correct? If so, is there a reason for this behavior?

Yes, Analysis Server reports a problem when the new name of a class member shadows a superclass member or will be shadowed by a subclass. I think this is useful to know in order to avoid accidental overrides. Why this is not the case of shadowing abstract class members?

For Analysis Server this is not a fatal error, it just says that there is a class member that will be shadowed and provides location of the member - the file and the source range. But the Dart plugin for IDEA handles these issues as fatal and does not allow you to perform the refactoring. I think this problem should be fixed in the Dart plugin, to improve its UI and allow users to review the potential problems and then make decisions.

@jwren

FYI @alexander-doroshko

Yes, allowing a choice sounds better, for both abstract and concrete. Thanks!

Please file an issue in JetBrains issue tracker (Subsystem: Dart). Thanks!

P.S. #27497 looks like the same, also filed in a wrong issue tracker, so not noticed :)

@alexander-doroshko I don't see a project named Dart -- or any reference to subsystems -- could you point me in the right direction please?

Click Create Issue first :)

Found it under "Project -- WebStorm _ IntelliJ Web", then subsystem appears as one of many fields on the right. Filed here:

https://youtrack.jetbrains.com/issue/WEB-25913

Thanks!

Was this page helpful?
0 / 5 - 0 ratings