[2.3.2 Scala] Weird routes error

102 views
Skip to first unread message

Amir Karimi

unread,
Jul 22, 2014, 3:17:09 PM7/22/14
to play-fr...@googlegroups.com
Migrating from 2.2.x to 2.3.2, got this compiler error:

type mismatch; found : play.api.mvc.Action[_$1(in value $anonfun)] where type _$1(in value $anonfun) required: play.api.mvc.Action[_$1(in lazy value controllers_admin_FileController_getList4_invoker)]

On this route:

GET /file/getlist @controllers.admin.FileController.getList(folderId: Option[BSONObjectID] ?= None, fileId: Option[BSONObjectID] ?= None, fileType: Option[String] ?= None)

What it means?!
--
Amir Karimi

A. Karimi

unread,
Jul 25, 2014, 2:48:05 PM7/25/14
to play-fr...@googlegroups.com
Return type of `getList` was `Action[_]` which causes this problem. After making its return type to `Aciton[AnyContent]` everything is Ok.

Devon Stewart

unread,
Mar 27, 2015, 9:03:36 PM3/27/15
to play-fr...@googlegroups.com
I'm getting this error when using a parameterized JSON BodyParser:

POST          /item/:itemId/editComplete                                        @controllers.ItemsController.editComplete(itemId:Long)

That maps to:

  case class EditViewModel(isSelected: Boolean, description: String, title: Option[String])
 
implicit val editViewModelFormat = Json.format[EditViewModel]

 
def editComplete(itemId: Long) = Authenticated(parse.json[EditViewModel]) { implicit request =>

giving the following error message:

[error] .../conf/routes:98: type mismatch;
[error]  found   : play.api.mvc.Action[_48335.type(in value $anonfun)#EditViewModel] where type _48335.type(in value $anonfun) <: controllers.ItemsController with Singleton
[error]  required: play.api.mvc.Action[_48335.type(in lazy value controllers_ItemsController_editComplete62_invoker)#EditViewModel]
[error] POST          /item/:itemId/editComplete                                        @controllers.ItemsController.editComplete(itemId:Long)
[warn] .../conf/routes:98: inferred existential type play.core.Router.HandlerInvoker[play.api.mvc.Action[_48335.EditViewModel]] forSome { val _48335: controllers.ItemsController }, which cannot be expressed by wildcards,  should be enabled
[warn] by making the implicit value scala.language.existentials visible.
[warn] This can be achieved by adding the import clause 'import scala.language.existentials'
[warn] or by setting the compiler option -language:existentials.
[warn] See the Scala docs for value scala.language.existentials for a discussion
[warn] why the feature should be explicitly enabled.
[warn] POST          /item/:itemId/editComplete                                        @controllers.ItemsController.editComplete(itemId:Long)
[warn] one warning found

I wonder if I need to make the JSON formats available in routes somehow? Maybe get the class in scope?

-Devon
Reply all
Reply to author
Forward
0 new messages