Question

When I compile my program it compiles well, however, when I run scaladoc it doesn't work. Here is the minimal code where sbt compile compiles well and sbt doc does not work:

/**
* Doc here.
*/
object SigmaDDFactoryImpl {
lazy val ipfFactory = new SigmaDDIPFFactoryImpl {
  val inductiveIPFFactory = new SigmaDDInductiveIPFFactoryImpl {
    val sigmaDDFactory: SigmaDDFactoryImpl.this.type = SigmaDDFactoryImpl.this
  }
}
class SigmaDD
}

/**
* Doc here.
*/
abstract class SigmaDDIPFFactoryImpl {
type InductiveIPFType = inductiveIPFFactory.InductiveTypeImpl

val inductiveIPFFactory:SigmaDDInductiveIPFFactoryImpl
}

class SigmaDDInductiveIPFFactoryImpl {
class InductiveTypeImpl
object MyObj extends InductiveTypeImpl
}

/**
* Doc here.
*/

class OtherClass {
 type InductiveIPF = SigmaDDFactoryImpl.ipfFactory.InductiveIPFType

def method(inductiveElt:InductiveIPF) = inductiveElt match {
  case a:SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveTypeImpl => None
  case SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.MyObj => None
}
}

Here is the output of sbt doc:

[info] Set current project to scaladocbugtest (in build file:/Users/mundacho/temp/scaladocBugTest/)
[info] Main Scala API documentation to /Users/mundacho/temp/scaladocBugTest/target/scala-2.10/api...
[error] /Users/mundacho/temp/scaladocBugTest/src/main/scala/TestClass.scala:35: pattern type is incompatible with expected type;
[error]  found   : SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveTypeImpl
[error]  required: SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveTypeImpl
[error]     case a:SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveTypeImpl => None
[error]                                                              ^
[error] /Users/mundacho/temp/scaladocBugTest/src/main/scala/TestClass.scala:36: pattern type is incompatible with expected type;
[error]  found   : SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.MyObj.type
[error]  required: OtherClass.this.InductiveIPF
[error]     (which expands to)  SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveTypeImpl
[error] Note: if you intended to match against the class, try `case _: <none>`
[error]     case SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.MyObj => None
[error]                                                            ^
[info] No documentation generated with unsucessful compiler run
[error] two errors found
[error] (compile:doc) Scaladoc generation failed
[error] Total time: 1 s, completed 11 oct. 2013 14:04:25

I'm using sbt 0.13 and scala 2.10.2. How to make this code work?

Was it helpful?

Solution

The solution I found is:

/**
* Doc here.
*/
object SigmaDDFactoryImpl {
lazy val ipfFactory = new SigmaDDIPFFactoryImpl {
  val inductiveIPFFactory = new SigmaDDInductiveIPFFactoryImpl // I removed the braces here
}
class SigmaDD
}

/**
* Doc here.
*/
abstract class SigmaDDIPFFactoryImpl {
type InductiveIPFType = inductiveIPFFactory.InductiveTypeImpl

val inductiveIPFFactory:SigmaDDInductiveIPFFactoryImpl
}

class SigmaDDInductiveIPFFactoryImpl {
class InductiveTypeImpl
object MyObj extends InductiveTypeImpl
}

/**
* Doc here.
*/

class OtherClass {
 type InductiveIPF = SigmaDDFactoryImpl.ipfFactory.InductiveIPFType

def method(inductiveElt:InductiveIPF) = inductiveElt match {
  case a:SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveTypeImpl => None
  case SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.MyObj => None
}
}

However, I still wonder why scaladoc needs to compile the code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top