GROOVY-5610: adding test case to avoid regression
improve bug error message for mismatched declaring class