Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-5866 Support casting null to value classes
The fix now supports null.asInstanceOf[C] where C is a value class that wraps a primitive type.
- Loading branch information
Showing
3 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
0.0 | ||
Foo(0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Foo(val d: Double) extends AnyVal { | ||
override def toString = s"Foo($d)" | ||
} | ||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val d: Double = null.asInstanceOf[Double] | ||
println(d) | ||
val f: Foo = null.asInstanceOf[Foo] | ||
println(f) | ||
} | ||
} |