Skip to content

Commit 4f836b1

Browse files
committed
handle multiple arguments, not only the first one
1 parent 4b554f2 commit 4f836b1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

analyzer/src/main/scala/com/avsystem/commons/analyzer/ThrownExceptionNotInFunction.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ final class ThrownExceptionNotInFunction(g: Global) extends AnalyzerRule(g, "thr
88
import global.*
99

1010
def analyze(unit: CompilationUnit): Unit = unit.body.foreach(analyzeTree {
11-
case t@Apply(f: TypeApply, List(Throw(_))) if definitions.isFunctionType(f.tpe.params.head.tpe) =>
12-
report(t.pos, "exception thrown in place of function definition")
11+
case Apply(f: TypeApply, args: List[Tree]) =>
12+
args.zip(f.tpe.params).foreach {
13+
case (arg: Throw, param) if definitions.isFunctionType(param.tpe) =>
14+
report(arg.pos, "exception thrown in place of function definition")
15+
case (_, _) =>
16+
}
1317
})
1418
}

analyzer/src/test/scala/com/avsystem/commons/analyzer/ThrownExceptionNotInFunctionTest.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,3 @@ final class ThrownExceptionNotInFunctionTest extends AnyFunSuite with AnalyzerTe
8080
}
8181
}
8282
}
83-

0 commit comments

Comments
 (0)