Skip to content

Commit ea63740

Browse files
Merge pull request #13316 from BarkingBad/tasty-inspector
Update the tasty inspector returned value
2 parents 1212b8c + 48121d8 commit ea63740

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ object BootstrappedStdLibTASYyTest:
109109
()
110110
}
111111
val tastyFiles = scalaLibTastyPaths.filterNot(blacklisted)
112-
val hasErrors = TastyInspector.inspectTastyFiles(tastyFiles.map(x => scalaLibClassesPath.resolve(x).toString))(inspector)
113-
assert(!hasErrors, "Errors reported while loading from TASTy")
112+
val isSuccess = TastyInspector.inspectTastyFiles(tastyFiles.map(x => scalaLibClassesPath.resolve(x).toString))(inspector)
113+
assert(isSuccess, "Errors reported while loading from TASTy")
114114

115115
def compileFromTastyInJar(blacklisted: Set[String]): Unit = {
116116
val driver = new dotty.tools.dotc.Driver

tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ object TastyInspector:
2222
/** Load and process TASTy files using TASTy reflect
2323
*
2424
* @param tastyFiles List of paths of `.tasty` files
25+
*
26+
* @return boolean value indicating whether the process succeeded
2527
*/
2628
def inspectTastyFiles(tastyFiles: List[String])(inspector: Inspector): Boolean =
2729
inspectAllTastyFiles(tastyFiles, Nil, Nil)(inspector)
2830

2931
/** Load and process TASTy files in a `jar` file using TASTy reflect
3032
*
3133
* @param jars Path of `.jar` file
34+
*
35+
* @return boolean value indicating whether the process succeeded
3236
*/
3337
def inspectTastyFilesInJar(jar: String)(inspector: Inspector): Boolean =
3438
inspectAllTastyFiles(Nil, List(jar), Nil)(inspector)
@@ -38,6 +42,8 @@ object TastyInspector:
3842
* @param tastyFiles List of paths of `.tasty` files
3943
* @param jars List of path of `.jar` files
4044
* @param dependenciesClasspath Classpath with extra dependencies needed to load class in the `.tasty` files
45+
*
46+
* @return boolean value indicating whether the process succeeded
4147
*/
4248
def inspectAllTastyFiles(tastyFiles: List[String], jars: List[String], dependenciesClasspath: List[String])(inspector: Inspector): Boolean =
4349
def checkFile(fileName: String, ext: String): Unit =
@@ -49,7 +55,7 @@ object TastyInspector:
4955
tastyFiles.foreach(checkFile(_, "tasty"))
5056
jars.foreach(checkFile(_, "jar"))
5157
val files = tastyFiles ::: jars
52-
files.nonEmpty && inspectFiles(dependenciesClasspath, files)(inspector)
58+
inspectFiles(dependenciesClasspath, files)(inspector)
5359

5460
private def inspectorDriver(inspector: Inspector) =
5561
class InspectorDriver extends Driver:
@@ -100,11 +106,11 @@ object TastyInspector:
100106

101107

102108
private def inspectFiles(classpath: List[String], classes: List[String])(inspector: Inspector): Boolean =
103-
if (classes.isEmpty)
104-
throw new IllegalArgumentException("Parameter classes should no be empty")
105-
106-
val reporter = inspectorDriver(inspector).process(inspectorArgs(classpath, classes))
107-
reporter.hasErrors
109+
classes match
110+
case Nil => true
111+
case _ =>
112+
val reporter = inspectorDriver(inspector).process(inspectorArgs(classpath, classes))
113+
!reporter.hasErrors
108114

109115
end inspectFiles
110116

0 commit comments

Comments
 (0)