-
Notifications
You must be signed in to change notification settings - Fork 21
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
Wildcard capture goes wrong on nested wildcard #9419
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9419?orig=1 |
Still broken in Scala 3. |
Dale and I noticed that it isn't crucial to have an actual byname; you can change the reproducer to use (Regardless, we should test any proposed fix on both variants.) |
I'm partial to this minimization (in Scala 3 syntax): trait Magic[S]:
def init: S
def step(s: S): String
object IntMagic extends Magic[Int]:
def init = 0
def step(s: Int): String = (s - 1).toString
object StrMagic extends Magic[String]:
def init = "hi"
def step(s: String): String = s.reverse
object Main:
def onestep[T](m: () => Magic[T]): String = m().step(m().init)
val iter: Iterator[Magic[?]] = Iterator(IntMagic, StrMagic)
def main(args: Array[String]): Unit =
onestep(() => iter.next()) it's not fundamentally different. Just a bit easier to grasp, perhaps.
|
scala/scala3#16732 is merged, so, labeling this one as "fixed in Scala 3" now UPDATE: see also discussion at scala/scala3#16789 |
errant auto-closing. not fixed in Scala 2. |
This should not compile; it should not be able to infer a
T
when callingonestep
. We use that to throw aClassCastException
.(scastie here) throws
This doesn't apply to the
Magic
variant from #9410, except if you do the intermediate introduction offorSome
, which is already introduced here.The text was updated successfully, but these errors were encountered: