error del compilador al usar guayaba de Google desde el código scala
Estoy usando Google Guava desde un código scala. Y ocurre un problema cuando intento usar Int como un tipo de clave como en el ejemplo:
CacheBuilder.newBuilder()
.maximumSize(2)
.expireAfterWrite(24, TimeUnit.HOURS)
.build(
new CacheLoader[Int, String] {
def load(path: Int): String = {
path + "hello"
}
}
)
Parece estar bien, pero el tipo inferido de objeto creado esLoadingCache [Int con AnyRef, String]:
val cache: LoadingCache[Int with AnyRef, String] = CacheBuilder.newBuilder()
.maximumSize(2)
.expireAfterWrite(24, TimeUnit.HOURS)
.build(
new CacheLoader[Int, String] {
def load(path: Int): String = {
path + "hello"
}
}
)
Y el error ocurre cuando intento obtener un elemento como en este ejemplo:
cache.get(1)
Error del compilador Scala:
[ERROR] error: type mismatch;
[INFO] found : Int(1)
[INFO] required: Int
[INFO] cache.get(1)
[INFO] ^
¿Alguien puede señalarme por qué aparece ese error y qué estoy haciendo mal?
ENV:
Google Guava 15.0Scala 2.11.5