diff --git a/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala b/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala index 54b89b1f5e3b..100292b1f5a7 100644 --- a/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala +++ b/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala @@ -109,8 +109,8 @@ object BootstrappedStdLibTASYyTest: () } val tastyFiles = scalaLibTastyPaths.filterNot(blacklisted) - val hasErrors = TastyInspector.inspectTastyFiles(tastyFiles.map(x => scalaLibClassesPath.resolve(x).toString))(inspector) - assert(!hasErrors, "Errors reported while loading from TASTy") + val isSuccess = TastyInspector.inspectTastyFiles(tastyFiles.map(x => scalaLibClassesPath.resolve(x).toString))(inspector) + assert(isSuccess, "Errors reported while loading from TASTy") def compileFromTastyInJar(blacklisted: Set[String]): Unit = { val driver = new dotty.tools.dotc.Driver diff --git a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala index ad171d12a8da..ab3f3e86357f 100644 --- a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala +++ b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala @@ -22,6 +22,8 @@ object TastyInspector: /** Load and process TASTy files using TASTy reflect * * @param tastyFiles List of paths of `.tasty` files + * + * @return boolean value indicating whether the process succeeded */ def inspectTastyFiles(tastyFiles: List[String])(inspector: Inspector): Boolean = inspectAllTastyFiles(tastyFiles, Nil, Nil)(inspector) @@ -29,6 +31,8 @@ object TastyInspector: /** Load and process TASTy files in a `jar` file using TASTy reflect * * @param jars Path of `.jar` file + * + * @return boolean value indicating whether the process succeeded */ def inspectTastyFilesInJar(jar: String)(inspector: Inspector): Boolean = inspectAllTastyFiles(Nil, List(jar), Nil)(inspector) @@ -38,6 +42,8 @@ object TastyInspector: * @param tastyFiles List of paths of `.tasty` files * @param jars List of path of `.jar` files * @param dependenciesClasspath Classpath with extra dependencies needed to load class in the `.tasty` files + * + * @return boolean value indicating whether the process succeeded */ def inspectAllTastyFiles(tastyFiles: List[String], jars: List[String], dependenciesClasspath: List[String])(inspector: Inspector): Boolean = def checkFile(fileName: String, ext: String): Unit = @@ -49,7 +55,7 @@ object TastyInspector: tastyFiles.foreach(checkFile(_, "tasty")) jars.foreach(checkFile(_, "jar")) val files = tastyFiles ::: jars - files.nonEmpty && inspectFiles(dependenciesClasspath, files)(inspector) + inspectFiles(dependenciesClasspath, files)(inspector) private def inspectorDriver(inspector: Inspector) = class InspectorDriver extends Driver: @@ -100,11 +106,11 @@ object TastyInspector: private def inspectFiles(classpath: List[String], classes: List[String])(inspector: Inspector): Boolean = - if (classes.isEmpty) - throw new IllegalArgumentException("Parameter classes should no be empty") - - val reporter = inspectorDriver(inspector).process(inspectorArgs(classpath, classes)) - reporter.hasErrors + classes match + case Nil => true + case _ => + val reporter = inspectorDriver(inspector).process(inspectorArgs(classpath, classes)) + !reporter.hasErrors end inspectFiles