我目前正在将应用程序的一部分移植到 scala,它使用 Oval 库。该方法的问题是 Validator.validate 方法。它有两个 签名:
List<ConstraintViolation> validate(Object validatedObject)
List<ConstraintViolation> validate(Object validatedObject, String... profiles)
scala 代码通常如下所示:
def validate(toValidate: AnyRef) = {
val validator = createValidator
validator.validate(toValidate)
}
和错误信息:
error: ambiguous reference to overloaded definition,
[INFO] both method validate in class Validator of type (x$1: Any,x$2: <repeated...>[java.lang.String])java.util.List[net.sf.oval.ConstraintViolation]
[INFO] and method validate in class Validator of type (x$1: Any)java.util.List[net.sf.oval.ConstraintViolation]
[INFO] match argument types (AnyRef)
[INFO] this.validator.validate(toValidate)
我怎样才能得到这个是明确的?