Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class tests extends CompilerTest {
@Test def neg_boundspropagation = compileFile(negDir, "boundspropagation", xerrors = 4)
@Test def neg_refinedSubtyping = compileFile(negDir, "refinedSubtyping", xerrors = 2)
@Test def neg_i0248_inherit_refined = compileFile(negDir, "i0248-inherit-refined", xerrors = 4)
@Test def neg_i0281 = compileFile(negDir, "i0281-null-primitive-conforms", xerrors = 3)

@Test def dotc = compileDir(dotcDir + "tools/dotc", twice)(allowDeepSubtypes)
@Test def dotc_ast = compileDir(dotcDir + "tools/dotc/ast", twice)
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i0281-null-primitive-conforms.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object test {
val b: scala.Boolean = null
val c: Unit = null
val d: Float = null
val e: AnyVal = null
}