2013-10-11 40 views
1

当我编译我的程序时,它编译得很好,但是,当我运行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。如何使这个代码工作?

+0

如果我没有弄错,scaladoc不会编译你的源代码。可能它会在你的情况下编译,因为'doc'目标取决于'compile'。如果你运行'sbt compile',我猜你会有同样的错误。 –

+0

尽管如此,看着你发布的输出,这确实是一个奇怪的错误,因为'(扩展为)'给你完全所需的类型。也许你遇到了一个编译器错误。尝试注释该类型,例如'(top:ch.unige.cui.smv.stratagem.sigmadd.SigmaDDFactoryImpl.ipfFactory.InductiveIPFType,false)' –

+0

@ 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

回答

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需要编译代码。

+0

我提交了一个错误报告:[SI-7905](https://issues.scala-lang.org/browse/SI-7905) –

+1

BTW:如果您删除__structural type__(用'sigmaDDFactory'完善)并写入' val inductiveIPFFactory:SigmaDDInductiveIPFFactoryImpl = new SigmaDDInductiveIPFFactoryImpl',doc也成功。 –