Skip to content

Commit

Permalink
handle multiple arguments, not only the first one
Browse files Browse the repository at this point in the history
  • Loading branch information
halotukozak committed Jun 19, 2024
1 parent 4b554f2 commit 4f836b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ final class ThrownExceptionNotInFunction(g: Global) extends AnalyzerRule(g, "thr
import global.*

def analyze(unit: CompilationUnit): Unit = unit.body.foreach(analyzeTree {
case t@Apply(f: TypeApply, List(Throw(_))) if definitions.isFunctionType(f.tpe.params.head.tpe) =>
report(t.pos, "exception thrown in place of function definition")
case Apply(f: TypeApply, args: List[Tree]) =>
args.zip(f.tpe.params).foreach {
case (arg: Throw, param) if definitions.isFunctionType(param.tpe) =>
report(arg.pos, "exception thrown in place of function definition")
case (_, _) =>
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe
}
}
}

0 comments on commit 4f836b1

Please sign in to comment.