This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Help fixing "non variable type-argument String in type pattern String => _ is unchecked since it is eliminated by erasure"

1 reply
Drew
Joined: 2011-12-16,
User offline. Last seen 42 years 45 weeks ago.

Hi Everyone,

I'm trying to fix the compilation warning in https://github.com/vspy/scala-mustache but I'm pretty new to Scala, so I still don't quite understand how to use Manifest. I tried reading Daniel's post [1], but still no luck.

These are the lines that give warnings:

non variable type-argument String in type pattern String => _ is unchecked since it is eliminated by erasure
https://github.com/vspy/scala-mustache/blob/master/src/main/scala/Mustac...

non variable type-argument String in type pattern (String, String => String) => _ is unchecked since it is eliminated by erasure
https://github.com/vspy/scala-mustache/blob/master/src/main/scala/Mustac...

non variable type-argument String in type pattern scala.collection.MapLike[String,_,_] is unchecked since it is eliminated by erasure
https://github.com/vspy/scala-mustache/blob/master/src/main/scala/Mustac...

Thanks,

Drew

[1] http://stackoverflow.com/questions/1094173/how-do-i-get-around-type-eras...

Lex
Joined: 2010-02-28,
User offline. Last seen 42 years 45 weeks ago.
Re: Help fixing "non variable type-argument String in type patt
The warning is telling you that there is no way of knowing at runtime if you are dealing with Function1[String, _] or Function1[Integer, _] or anything else that conforms to Function1[_, _].

The usual way to deal with this is to use Function1[_, _]. You may have to cast it before you use it.


On Thu, Jan 19, 2012 at 12:56 PM, Drew Kutcharian <drew@venarc.com> wrote:
Hi Everyone,

I'm trying to fix the compilation warning in https://github.com/vspy/scala-mustache but I'm pretty new to Scala, so I still don't quite understand how to use Manifest. I tried reading Daniel's post [1], but still no luck.

These are the lines that give warnings:

non variable type-argument String in type pattern String => _ is unchecked since it is eliminated by erasure
https://github.com/vspy/scala-mustache/blob/master/src/main/scala/Mustache.scala#L427

non variable type-argument String in type pattern (String, String => String) => _ is unchecked since it is eliminated by erasure
https://github.com/vspy/scala-mustache/blob/master/src/main/scala/Mustache.scala#L430

non variable type-argument String in type pattern scala.collection.MapLike[String,_,_] is unchecked since it is eliminated by erasure
https://github.com/vspy/scala-mustache/blob/master/src/main/scala/Mustache.scala#L443

Thanks,

Drew

[1] http://stackoverflow.com/questions/1094173/how-do-i-get-around-type-erasure-on-scala-or-why-cant-i-get-the-type-paramete


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland