Mixing private and public/protected methods of the same name causes multimethods to be disabled and is forbidden to avoid surprising behaviour

StackOverflow https://stackoverflow.com/questions/14339022

I just upgraded one of my Grails apps to 2.2.0 which is using Groovy 2.0 and I am now getting this compile error:

Mixing private and public/protected methods of the same name causes multimethods to be disabled and is forbidden to avoid surprising behaviour. Renaming the private methods will solve the problem.

Based on the following code:

def getRootDomain(key) { }

private getRootDomain() { }

It's an easy fix but I'd really like to understand the why better. Can someone explain this to me?

有帮助吗?

解决方案

It's because of the way groovy chooses which method to call, and its potential incompatibility with java.

Have you seen this thread on the mailing list?

http://groovy.329449.n5.nabble.com/mixing-public-private-overloaded-methods-causes-compilation-error-td367147.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top