should expected type stop singleton widening of nested expressions #17865
Replies: 0 comments 10 replies
-
I am skeptical to call this a bug, but asking for @smarter opinion on if expected type should prevent widening here |
Beta Was this translation helpful? Give feedback.
-
i think this is also a duplicate, will need to find the previous issue |
Beta Was this translation helpful? Give feedback.
-
@bishabosha Just to make sure: aren't |
Beta Was this translation helpful? Give feedback.
-
maybe conceptually, but |
Beta Was this translation helpful? Give feedback.
-
I think I may be misleading you here. I don't think its is just an issue of equivalence between Tuples and HLists (cons). More concretely, this also fails: val s14: *:[28, *:[28, *:[1.0, EmptyTuple]]] = 28 *: 28 *: 1.0 *: EmptyTuple I get:
Shouldn't that also work? Maybe it is another issue? Notice also how in val s12: Tuple3[28, Int, Double] = 28 *: 28 *: 1.0 *: Tuple()
val s15: *:[28, *:[Int, *:[Double, EmptyTuple]]] = 28 *: 28 *: 1.0 *: EmptyTuple We are able to get the first value type And in EDIT: value type should be singleton type. |
Beta Was this translation helpful? Give feedback.
-
you can replicate the issue with your own definition: sealed trait Tpl {
inline def **:[H, This >: this.type <: Tpl](h: H): H **: This = null.asInstanceOf[H **: This]
}
sealed trait NonEmptyTpl extends Tpl
case object EmpT extends Tpl
class **:[+H, +T <: Tpl] extends NonEmptyTpl
scala> val m: 1 **: 2 **: EmpT.type = 1 **: 2 **: EmpT
1 |val m: 1 **: 2 **: EmpT.type = 1 **: 2 **: EmpT
| ^^^^^^^^^^^^^^^^
| Found: Int **: Int **: EmpT.type
| Required: (1 : Int) **: (2 : Int) **: EmpT.type |
Beta Was this translation helpful? Give feedback.
-
so this is not really an issue with tuples |
Beta Was this translation helpful? Give feedback.
-
Maybe a change the issue title? |
Beta Was this translation helpful? Give feedback.
-
Singletons are only inferred as type arguments if the type parameter is bounded by |
Beta Was this translation helpful? Give feedback.
-
I guess in my intuition, expected type would unify more deeply in expressions rather than only the top level. Moved to feature-requests if this is as expected |
Beta Was this translation helpful? Give feedback.
-
Compiler version
3.0.0-RC1
Minimized code
Output
Expectation
I am assuming that Tuples with arity > 22 will be typed just as they are for lower arity. From the example above it seems like the tail of the HList is lost. Is this the expected behavior?
Beta Was this translation helpful? Give feedback.
All reactions