-
Notifications
You must be signed in to change notification settings - Fork 21
Closed as not planned
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)inferout of scope
Milestone
Description
It would be useful if asInstanceOf
inferred from the expected type.
The workaround is:
def cast[A](x: Any): A = x.asInstanceOf[A] // NB can infer Nothing and throw ClassCastException!
Some notes from @adriaanm:
currently it's typed like a selection
foo.AIO
-- could try to special case that in typedSelect to type check ascast(foo)
right now, the type param for asInstanceOf would not be in the context's undetParams when type checking its target
(from memory -- didn't look at the code)
Jasper-M, psilospore, plokhotnyuk, KisaragiEffective and Barak22
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)inferout of scope