當我編譯我的程序時,它編譯得很好,但是,當我運行scaladoc時它不起作用。這裏是最小的代碼,其中sbt compile
編譯好,sbt doc
不起作用:scaladoc不像編譯器那樣編譯
/**
* 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。如何使這個代碼工作?
如果我沒有弄錯,scaladoc不會編譯你的源代碼。可能它會在你的情況下編譯,因爲'doc'目標取決於'compile'。如果你運行'sbt compile',我猜你會有同樣的錯誤。 –
儘管如此,看着你發佈的輸出,這確實是一個奇怪的錯誤,因爲'(擴展爲)'給你完全所需的類型。也許你遇到了一個編譯器錯誤。嘗試註釋該類型,例如'(top:ch.unige.cui.smv.stratagem.sigmadd.SigmaDDFactoryImpl.ipfFactory.InductiveIPFType,false)' –
@ 0__'sbt compile'很好的編譯代碼,沒有錯誤。我試過你的建議,錯誤是一樣的 [error] /Users/mundacho/git/stratagem/src/main/scala/ch/unige/cui/smv/stratagem/sigmadd/OneRewriter.scala:51:type mismatch ; [錯誤]實測值:ch.unige.cui.smv.stratagem.sigmadd.SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveIPFImpl [錯誤]需要:ch.unige.cui.smv.stratagem.sigmadd.SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveIPFImpl [error] case _ =>(頂端:SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveIPFImpl,false) – mundacho