-
Notifications
You must be signed in to change notification settings - Fork 21
Sugar for tuples does not preserve singleton types. #837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-837?orig=1 |
@paulp said: |
@retronym said: scala> (x: x.type, x: x.type)
res3: (String, String) = (foo,foo)
scala> val y : (x.type, x.type) = (x, x)
y: (x.type, x.type) = (foo,foo)
scala> val y = (x : x.type, x : x.type)
y: (String, String) = (foo,foo)
scala> val y : (x.type, x.type) = (x, x)
y: (x.type, x.type) = (foo,foo)
scala> val y : (x.type, x.type) = (x : x.type, x : x.type)
y: (x.type, x.type) = (foo,foo)
scala> val y : (x.type, x.type) = (x, x) : (x.type, x.type)
y: (x.type, x.type) = (foo,foo) |
@retronym said (edited on May 30, 2013 8:15:50 PM UTC): scala> val x = ""
x: String = ""
scala> (x match { case y => y }): x.type
<console>:9: error: type mismatch;
found : y.type (with underlying type String)
required: x.type
(x match { case y => y }): x.type
^ // scala/tools/nsc/transform/patmat/MatchTranslation.scala:134
val selectorTp = repeatedToSeq(elimAnonymousClass(selector.tpe.widen.withoutAnnotations)) |
@milessabin is this of interest? |
@SethTisue yes it is. |
As of scala/scala#5310 the situation is, scala> val x = "foo"
x: String = foo
scala> Tuple2[x.type, x.type](x,x)
res0: (x.type, x.type) = (foo,foo)
scala> val y = (x : x.type, x : x.type)
y: (String, String) = (foo,foo)
scala> val y : (x.type, x.type) = (x, x)
y: (x.type, x.type) = (foo,foo)
scala> val y : (x.type, x.type) = (x : x.type, x : x.type)
y: (x.type, x.type) = (foo,foo)
scala> val y : (x.type, x.type) = (x, x) : (x.type, x.type)
y: (x.type, x.type) = (foo,foo) The widening in the scala> Tuple2(x: x.type, x: x.type)
res1: (String, String) = (foo,foo) which is the correct behaviour given the absence of So I'm declaring victory on this one. |
The following works:
But all of the following do not:
The text was updated successfully, but these errors were encountered: