Hello:
I am using playframework 2.6.7/scala 2.12.4 with Jdk 1.8.0_151 on a macos sierra computer. My ide is IntellijIdea.
I have a form with a mapping that "firstName" -> nonEmptyText(1, 3). When I post a value that has more than 3 characters, the error message generate is what you see in the attachment:
Having WrappedArray(3) appear is wrong, it should be only 3. The problem is that the args sequence contains one element which is itself a WrappedArray.
I attached some debugging screenshots.
I think the problem occurs because out of all the apply mathods in MessagesImpl, the compiler picked the first apply with args: Any*, instead of the last one. So args, gets wrapped inside another array.
case class MessagesImpl(lang: Lang, messagesApi: MessagesApi) extends Messages {
/**
* Translates a message.
*
* Uses `java.text.MessageFormat` internally to format the message.
*
* @param key the message key
* @param args the message arguments
* @return the formatted message or a default rendering if the key wasn’t defined
*/
override def apply(key: String, args: Any*): String = {
messagesApi(key, args: _*)(lang)
}
/**
* Translates the first defined message.
*
* Uses `java.text.MessageFormat` internally to format the message.
*
* @param keys the message key
* @param args the message arguments
* @return the formatted message or a default rendering if the key wasn’t defined
*/
override def apply(keys: Seq[String], args: Any*): String = {
messagesApi(keys, args: _*)(lang)
}
/**
* Translates a message.
*
* Uses `java.text.MessageFormat` internally to format the message.
*
* @param key the message key
* @param args the message arguments
* @return the formatted message, if this key was defined
*/
override def translate(key: String, args: Seq[Any]): Option[String] = {
messagesApi.translate(key, args)(lang)
}
How can I fix this? Is the bug in the scala compiler?
Thanks