1

当我编译我的程序时,它编译得很好,但是,当我运行 scaladoc 时它不起作用。这是sbt compile编译良好sbt doc但不起作用的最小代码:

/**
* 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
}
}

这是输出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

我正在使用 sbt 0.13 和 scala 2.10.2。如何使这段代码工作?

4

1 回答 1

0

我找到的解决方案是:

/**
* 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
}
}

但是,我仍然想知道为什么scaladoc需要编译代码。

于 2013-10-11T12:12:09.107 回答