Skip to content

Commit

Permalink
don't report expressions with Nothing type
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Janusz committed Nov 18, 2022
1 parent d3c7b59 commit 6b14a44
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ZerowastePhase extends PluginPhase {
}

private def notUnit(tree: Tree)(using Context): Boolean =
!(tree.tpe =:= defn.UnitType)
!(tree.tpe <:< defn.UnitType)

private def report(tree: Tree)(using Context): Unit =
dotty.tools.dotc.report.warning("discarded expression with non-Unit value", tree.srcPos)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.ghik.zerowaste

import org.scalatest.funsuite.AnyFunSuite
import dotty.tools.dotc.Compiler
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.plugins.Plugin
import dotty.tools.io.{Path, PlainFile}
import org.scalactic.source.Position
import org.scalatest.funsuite.AnyFunSuite

class ZerowastePluginTest extends AnyFunSuite {
val compiler = new Compiler
Expand Down
2 changes: 2 additions & 0 deletions testdata/zerowaste.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ object zerowaste {
}

// should not emit warnings
throw new Exception("nienie")

val t = com.github.ghik.zerowaste.Macro.inlinedValue // macro

class Klas(arg: Int) {
Expand Down

0 comments on commit 6b14a44

Please sign in to comment.