Details
Description
Problem
Executing the test from the sample below throws:
groovy.lang.MissingMethodException: No signature of method: static simple.groovy.bugs.gb_2021_03_04.TableGeneric.reference() is applicable for argument types: (String) values: [FOO_schema]
even though TableGeneric's base class Table has a public method with signature:
Table reference(String)
It seems this method is hidden by the static Table method:
static <T extends Table> T reference(T table)
Expected
Table#reference(String) should be called inside TableGeneric#reference() .
Sample Code
import org.junit.Ignore import org.junit.Test class GroovyBugs_2021_03_04 { @Test @Ignore void 'Groovy 2-5-14 TableGeneric#reference() MissingMethodException'() { final TableGeneric tableGeneric = new TableGeneric("FOO") println tableGeneric.reference() } }
import groovy.transform.Canonical @Canonical class Table { final String name = "defaultTable" Table reference(String schema) { println "${this.getClass().simpleName}#reference(schema): schema=$schema" return this } // Commenting out this static method gets rid of the error static <T extends Table> T reference(T table) { println "Table.reference(table): table=$table" assert null != table return table } }
import groovy.transform.InheritConstructors @InheritConstructors class TableGeneric extends Table { // If this method takes an argument, the error disappears TableGeneric reference() { println "${this.getClass().simpleName}#reference(): name=$name" final String schema = "${name}_schema" /* Passing schema = null leads to Table.reference(T table) being called with table=null */ return (TableGeneric) super.reference(schema) } }