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