Scala existentials placeholder translation for M[_,_] where M[X,Y <: N[X]] -


given following types

trait n[x] trait m[x, y <: n[x]] 

how scala translate this:

m[_,_] 

i've tried following without success:

scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._  scala> typeof[class[_]] =:= typeof[class[c] forsome { type c }] res4: boolean = true  scala> typeof[list[class[_]]] =:= typeof[list[class[c] forsome { type c }]] res5: boolean = true  scala> typeof[m[_,_]] =:= typeof[m[x,y] forsome { type x; type y <: n[x] }] res5: boolean = false  warning: existential type m[x,y] forsome { type x; type y <: n[x] }, cannot expressed wildcards,   should enabled making implicit value scala.language.existentials visible. 

quite puzzling? if cannot expressed wildcards compiler should produce error rather warning, shouldn't it?

scala translates m[_,_] m[x, y] forsome { type x; type y }. proven:

scala> type foo = m[_,_] defined type alias foo  scala> type bar = m[x, y] forsome { type x; type y } defined type alias bar  scala> implicitly[ foo =:= bar] res0: =:=[foo,bar] = <function1> 

or using reflection:

scala> typeof[foo] =:= typeof[bar] res2: boolean = true 

as warning get, says m[x,y] forsome { type x; type y <: n[x] } has no equivalent using wildcards. wildcards syntactic sugar limited subset of existential types, , scala compiler considers existentials advanced feature should enable explicitly, hence warning (unless existential can mapped simple wildcards, compiler not consider advanced feature mandate explicitly enabled, why warning mentions existential cannot expressed wildcards).


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -