You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was reading over dotty's new type lambda syntax and exploring its feature when i came across an observation when i declared the following expressions in dotty's REPL (Using Dotty 0.3-RC1):
scala>typeT= [X, _] => (X,X)
scala>valt:T[Int, _] = (1,2)
valt:Int, Int= (1,2) // the wildcard "inherited the 'Int' type"
I guess my question is whether this is legal because in Scala, it seems to interpret to Nothing.
Another example is the following using dotty's REPL
val t : Int, Int = (1,2) // the wildcard "inherited the 'Int' type"
I think you're confused, what happened here is that T[Int, _] was replaced by its definition (Int, Int) (the fact that the repl prints val t: Int, Int instead of val t: (Int, Int) is a bug that does not occur anymore on master). The wildcard never "inherited" anything.
scala> val a : (Float, _) = (1f, 222)
val a: Float, _ = (1.0,222)
a._2
val res2: a.T2 = 222 // <---- a.T2 is a type that has not been resolved? Was expecting it to be 'Any'
No, it's a path-dependent type, but it doesn't really make sense here because the type parameter T2 of Tuple is not publically accessible. Using the in-progress #3033 we get val res2: Any = 222 as expected.
I was reading over dotty's new type lambda syntax and exploring its feature when i came across an observation when i declared the following expressions in dotty's REPL (Using Dotty
0.3-RC1
):I guess my question is whether this is legal because in Scala, it seems to interpret to
Nothing
.Another example is the following using dotty's REPL
Last example w.r.t type lambdas in tuples is what seems like the usual arithmetic promotion rules in Java/Scala:
The text was updated successfully, but these errors were encountered: