Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilesInfo.exists(...) is typed incorrectly #4952

Open
eed3si9n opened this issue Aug 15, 2019 · 0 comments
Open

FilesInfo.exists(...) is typed incorrectly #4952

eed3si9n opened this issue Aug 15, 2019 · 0 comments
Labels

Comments

@eed3si9n
Copy link
Member

eed3si9n commented Aug 15, 2019

steps

scala> FilesInfo.exists(file("/tmp/target").globRecursive("*.js").get.toSet)
res42: sbt.util.FilesInfo[_1.F] forSome { val _1: sbt.util.FileInfo.Style } = FilesInfo(Set())

problem

FilesInfo.exists(...) returns an existential type argument sbt.util.FilesInfo[_1.F] forSome { val _1: sbt.util.FileInfo.Style }.

expectation

It should return FilesInfo[PlainFileInfo] otherwise it's useless.

note

scala> import sbt._, sbt.util.CacheImplicits._
import sbt._
import sbt.util.CacheImplicits._

// use streams.value.cacheStoreFactory
scala> val cacheFactory = sbt.util.CacheStoreFactory(file("/tmp/cache"))
cacheFactory: sbt.util.CacheStoreFactory = sbt.util.DirectoryStoreFactory@3a3d3778

scala> def doCompile(source: File): File = {
         println("working...")
         val out = file("/tmp/target/hello.js")
         IO.touch(out)
         out
       }
doCompile: (source: sbt.File)sbt.File

scala> val cachedCompile = Tracked.inputChanged(cacheFactory.make("input")) {
         (inChanged: Boolean, in: FilesInfo[ModifiedFileInfo]) =>
           val tracker = Tracked.outputChanged(cacheFactory.make("output")) {
             (outChanged: Boolean, outputs: FilesInfo[PlainFileInfo]) =>
               if (inChanged || outChanged) in.files.toList map { info => doCompile(info.file) }
               else outputs.files.toList map { _.file }
           }
           tracker(() => FilesInfo.exists(file("/tmp/target").globRecursive("*.js").get.toSet))
       }
<console>:26: error: type mismatch;
 found   : sbt.util.FilesInfo[_1.F] where val _1: sbt.util.FileInfo.Style
 required: sbt.FilesInfo[sbt.PlainFileInfo]
    (which expands to)  sbt.util.FilesInfo[sbt.util.PlainFileInfo]
                  tracker(() => FilesInfo.exists(file("/tmp/target").globRecursive("*.js").get.toSet))
                                                ^

workaround

Cast it to FilesInfo[PlainFileInfo] using asInstanceOf[FilesInfo[PlainFileInfo]] or use Seq[PlainFileInfo].

@eed3si9n eed3si9n added the Bug label Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant