Where does the type erasure happen and what is a safe way to stay away from this?

def decode(l: List[(Int, Symbol)]) : List[Symbol] = {
    def foo(r : Int, s: Symbol):List[Symbol] = r match {
      case 0 => Nil
      case x: Int => s::foo(r-1,s)

    l match {
      case Nil => Nil
      case h::tail => foo(h._1 , h._2 ) :+ decode(tail)


Here I get a compilation error "scala: type mismatch; found:List[Object] required: List[Symbol] case h::tail => foo(h._1 : Int, h._2 : Symbol) :+ decode(tail) "


It is not a type erasure, simple type mismatch:

foo(h._1 , h._2 ) :+ decode(tail)

Result of foo is List[Symbol], result of decode is List[Symbol]. Now you're trying to put List inside List, no surprize that compiler thinks that the only way to store List and Symbols inside List is to give that later list Object (Any) type.

Most likely you wanted to simply combine two lists:

foo(h._1 , h._2 ) ++ decode(tail)

Need Your Help

Open iPhone/iPad settings panel

ios xcode settings

My app needs feature to open iPhone/iPad "Mail, contacts, Calendars" settings panel and automatically scroll to view default calendar settings row. Any sample or idea?

Error H13 (Connection Closed without response) Heroku

heroku ruby-on-rails-3.2

I am working on Ruby on Rails. A project which works fine on local server and when I deploy it on heroku it gives following error. Thanks!