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