Skip to content

Commit

Permalink
lil enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
halotukozak committed Jun 24, 2024
1 parent da13377 commit 0c3b54c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ final class ThrownExceptionNotInFunction(g: Global) extends AnalyzerRule(g, "thr
import global.*

def analyze(unit: CompilationUnit): Unit = unit.body.foreach(analyzeTree {
case Apply(f: TypeApply, args: List[Tree]) =>
case Apply(f: Tree, args: List[Tree]) =>
args.zip(f.tpe.params).foreach {
case (arg: Throw, param) if definitions.isFunctionType(param.tpe) =>
case (arg, param) if definitions.isFunctionType(param.tpe) && arg.tpe <:< definitions.NothingTpe =>
report(arg.pos, "exception thrown in place of function definition")
case (_, _) =>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe
| f0(throw ex)
|
| //ok
// | f0(identity)
| f0(identity)
|}""".stripMargin)
}

Expand Down

0 comments on commit 0c3b54c

Please sign in to comment.