Skip to content

Commit 6e7209f

Browse files
Avoid null in the scripting driver
1 parent d59bec7 commit 6e7209f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/src/dotty/tools/scripting/ScriptingDriver.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ class ScriptingDriver(compilerArgs: Array[String], scriptFile: File, scriptArgs:
5959
yield membersMainMethod
6060
else if target.getName.endsWith(".class") then
6161
val cls = cl.loadClass(targetPath)
62-
val method =
63-
try cls.getMethod("main", classOf[Array[String]])
64-
catch
65-
case _: java.lang.NoSuchMethodException => null
66-
67-
if method != null && Modifier.isStatic(method.getModifiers) then List(method)
68-
else Nil
62+
try
63+
val method = cls.getMethod("main", classOf[Array[String]])
64+
if Modifier.isStatic(method.getModifiers) then List(method) else Nil
65+
catch
66+
case _: java.lang.NoSuchMethodException => Nil
6967
else Nil
7068
end collectMainMethods
7169

0 commit comments

Comments
 (0)