Skip to content

docJar fails if code depends on scalac options #336

@keynmol

Description

@keynmol

Simplest example:

core/src/Main.scala

import scala.collection.immutable.SortedMap

object Main extends App {
  def foo[F[_], A](fa: F[A]): String = fa.toString
  foo { x: Int => x * 2 }
}

build.sc

object core extends ScalaModule {
    def scalaVersion = "2.12.4"
    
    def scalacOptions = super.scalacOptions() ++ Seq(
    "-Ypartial-unification"
    )
}

This is because docJar doesn't pass plugin options to ScalaDoc call (compile passes):

error: no type parameters for method foo: (fa: F[A])String exist so that it can be applied to arguments (Int => Int)
 --- because ---
argument expression's type is not compatible with formal parameter type;
 found   : Int => Int
 required: ?F[?A]
  foo { x: Int => x * 2 }
  ^
...
warning: there was one feature warning; re-run with -feature for details
model contains 3 documentable templates
one warning found
two errors found
1 targets failed
foo.docJar ammonite.ops.InteractiveShelloutException
    mill.modules.Jvm$.subprocess(Jvm.scala:180)
    mill.scalalib.ScalaModule.$anonfun$docJar$2(ScalaModule.scala:119)
    mill.define.ApplyerGenerated.$anonfun$zipMap$3(ApplicativeGenerated.scala:9)
    mill.define.Task$MappedDest.evaluate(Task.scala:348)

Metadata

Metadata

Assignees

No one assigned

    Labels

    solvedThe issue was fixed/resolved

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions