You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by MG <mg...@arscreat.com> on 2018/04/24 23:50:57 UTC

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

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 Baseimplements BaseIntf {
   Stringname Base(String name) {this.name = name }
   abstract Base getInstance1()
   static String makeName(String n,int i) {"$n$i" }
}

// foooPackage class Foooextends Base {
   static final Foooinstance0 static final Foooinstance1 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 }