0

I have a piece of code where I am explicitly passing a type parameter which is picked up just fine by intelliJ and there is no error pointed out by intelliJ, but when I use system sbt to compile the same code it doesn't pick up the type parameter and get confused with multiple matching implicit types in the scope.

Code in intelliJ with no error flagged :Code in intelliJ with no error flagged :

Error stack when compiled on system sbt :

[error] one error found
[error] /Users/xxxxxx/projects/xxxxx-xxxxxx-xxxxxx/xxxxxxxxx/src/main/scala/com/xxxxxxx/Main.scala:93:33: ambiguous implicit values:
[error]  both lazy value AsyncBlobIO in trait Instances of type => cats.effect.Async[doobie.free.BlobIO]
[error]  and lazy value AsyncCallableStatementIO in trait Instances of type => cats.effect.Async[doobie.free.CallableStatementIO]
[error]  match expected type cats.effect.Sync[F]
[error]               result <- jobPaths(Paths.get(record.path), settings.baseFolder).use(paths => ingestionJob(record, paths))
[error]                                 ^

As you can see the system sbt doesn't pick type argument jobPaths[IO](..) instead just runs jobPaths(..) for some reason.

JobPaths functions definition if that helps :

  def runJob[F[_]](
    settings: Settings,
    now: Instant,
    consulSessionName: String,
    assignerConfig: PartitionKeyAssignerConfig
  )(implicit F: ConcurrentEffect[F], p: Parallel[F]): F[Unit] = {

system sbt version :

[info]  1.2.8
sbt script version: 1.3.12

Am I looking at the problem the right way? or this is caused by something else?

Anything would be helpful.

1 Answers1

3

System sbt which uses Scala compiler proper is authoritative over IntelliJ Scala compiler. When the two disagree you should go with former. Make sure to enable use sbt shell to minimise discrepancies. Note that even with use sbt shell enabled the in-editor error highlighting might give false positives because it uses a separate process from Scala proper. An alternative to consider is Metals which should not have such discrepancies.

laughedelic
  • 6,230
  • 1
  • 32
  • 41
Mario Galic
  • 47,285
  • 6
  • 56
  • 98