Error:Groovyc: Abstract method 'getInstance1' is not implemented but a method of the same name but different return type is defined

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
MG
Reply | Threaded
Open this post in threaded view
|

Error:Groovyc: Abstract method 'getInstance1' is not implemented but a method of the same name but different return type is defined

MG
With regards to the problem described by Schalk Cronjé: This is the persistent, non-deterministic build problem I have had in Groovy since groovy-2.1.x up to groovy-2.4.x and IntelliJ_CE_13_1_3 to IntelliJ2017_3:

The schematic code shown below (which exists in similar from in
the code multiple times) sometimes throws the following error during a (larger) minimal rebuild:

Error:Groovyc: Abstract method 'basePackage.getInstance1' is not implemented but a method of the same name but different return type is defined: method 'foooPackage.
getInstance1'
 
The error disappears through just restarting the build multiple times. Rebuilding the same module multiple times in a row seems to have a much higher chance of the build failing again (starting a minimal rebuild of the whole project takes forever and is practically guaranteed to fail).

Cheers,
mg


interface BaseIntf {
  BaseIntf getInstance1()
}

// basePackage
abstract class Base implements BaseIntf {
  String name
  Base(String name) { this.name = name }
  abstract Base getInstance1()
  static String makeName(String n, int i) { "$n$i" }
}

// foooPackage
class Fooo extends Base {
  static final Fooo instance0
  static final Fooo instance1

  static {
    instance0 = new Fooo('ABC')
    instance1 = new Fooo(makeName(instance0.name,1))
  }

  protected Fooo(String name) { super(name) }

  @Override Fooo getInstance1() { return instance1 }  // Leads to indeterministic bug
  //@Override Base getInstance1() { return instance1 }  // Works
}