Skip to content

Commit 1145c87

Browse files
committed
Simplify DottyPlugin.dottyPatchIncOptions
1 parent 9709b08 commit 1145c87

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ object DottyPlugin extends AutoPlugin {
112112
* corresponding .tasty or .hasTasty file is also deleted.
113113
*/
114114
def dottyPatchIncOptions(incOptions: IncOptions): IncOptions = {
115-
val inheritedNewClassFileManager = ClassFileManagerUtil.getDefaultClassFileManager(incOptions)
116115
val tastyFileManager = new ClassFileManager {
117-
private[this] val inherited = inheritedNewClassFileManager
116+
private[this] val inherited =
117+
ClassFileManagerUtil.getDefaultClassFileManager(incOptions)
118118

119119
def delete(classes: Array[File]): Unit = {
120120
val tastySuffixes = List(".tasty", ".hasTasty")
121-
inherited.delete(classes flatMap { classFile =>
122-
if (classFile.getPath endsWith ".class") {
121+
inherited.delete(classes.flatMap { classFile =>
122+
if (classFile.getPath.endsWith(".class")) {
123123
val prefix = classFile.getAbsolutePath.stripSuffix(".class")
124124
tastySuffixes.map(suffix => new File(prefix + suffix)).filter(_.exists)
125125
} else Nil
@@ -129,16 +129,10 @@ object DottyPlugin extends AutoPlugin {
129129
def generated(classes: Array[File]): Unit = {}
130130
def complete(success: Boolean): Unit = {}
131131
}
132-
val inheritedHooks = incOptions.externalHooks
133-
val externalClassFileManager: Optional[ClassFileManager] = Option(inheritedHooks.getExternalClassFileManager.orElse(null)) match {
134-
case Some(prevManager) =>
135-
Optional.of(WrappedClassFileManager.of(prevManager, Optional.of(tastyFileManager)))
136-
case None =>
137-
Optional.of(tastyFileManager)
138-
}
139132

140-
val hooks = new DefaultExternalHooks(inheritedHooks.getExternalLookup, externalClassFileManager)
141-
incOptions.withExternalHooks(hooks)
133+
val newExternalHooks =
134+
incOptions.externalHooks.withExternalClassFileManager(tastyFileManager)
135+
incOptions.withExternalHooks(newExternalHooks)
142136
}
143137

144138
override val globalSettings: Seq[Def.Setting[_]] = Seq(

0 commit comments

Comments
 (0)