diff options
author | Martin Odersky <odersky@gmail.com> | 2014-12-13 19:15:47 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-12-13 19:15:58 +0100 |
commit | 9f87127c40a2b8ac0c8f97d039053e4d2f7577e4 (patch) | |
tree | acf8cc3575bcc625aaf7e1715ba60a0c71b89b1b /src | |
parent | f3d887f079efbe7dbb53abd22bd212eee8e1c67a (diff) | |
download | dotty-9f87127c40a2b8ac0c8f97d039053e4d2f7577e4.tar.gz dotty-9f87127c40a2b8ac0c8f97d039053e4d2f7577e4.tar.bz2 dotty-9f87127c40a2b8ac0c8f97d039053e4d2f7577e4.zip |
Disable implicit conversions between from `Null` and `Nothing`.
This is necessary to reject code like
val x: Boolean = null
Without the restriction, this code would typecheck and expand to
val x: Boolean = Predef.Boolean2boolean(null)
since `null` counts as a value of type `java.kang.Boolean`.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 90d1ceefb..82424164a 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -400,7 +400,9 @@ trait Implicits { self: Typer => def inferView(from: Tree, to: Type)(implicit ctx: Context): SearchResult = track("inferView") { if ( (to isRef defn.AnyClass) || (to isRef defn.ObjectClass) - || (to isRef defn.UnitClass)) NoImplicitMatches + || (to isRef defn.UnitClass) + || (from.tpe isRef defn.NothingClass) + || (from.tpe isRef defn.NullClass)) NoImplicitMatches else try inferImplicit(to.stripTypeVar.widenExpr, from, from.pos) catch { |