1

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?

mundacho
  • 229
  • 1
  • 8
  • scaladoc does _not_ compile your sources, if I'm not mistaken. Probably it compiles in your case because the `doc` target depends on `compile`. If you run `sbt compile` my guess is you will have the same error. – 0__ Oct 11 '13 at 10:02
  • Nevertheless, looking at the output you posted, this is indeed a strange error, since `(which expands to)` gives you exactly the required type. Perhaps you ran into a compiler bug. Try annotating the type, e.g. `(top: ch.unige.cui.smv.stratagem.sigmadd.SigmaDDFactoryImpl.ipfFactory.InductiveIPFType, false)` – 0__ Oct 11 '13 at 10:04
  • @0__ `sbt compile` compiles the code well, with no errors. I tried your advice and the error is the same [error] /Users/mundacho/git/stratagem/src/main/scala/ch/unige/cui/smv/stratagem/sigmadd/OneRewriter.scala:51: type mismatch; [error] found : ch.unige.cui.smv.stratagem.sigmadd.SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveIPFImpl [error] required: ch.unige.cui.smv.stratagem.sigmadd.SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveIPFImpl [error] case _ => (top:SigmaDDFactoryImpl.ipfFactory.inductiveIPFFactory.InductiveIPFImpl, false) – mundacho Oct 11 '13 at 11:24
  • Really strange. Could you post the whole method where it fails, and the whole sbt output when you run `sbt doc`? – 0__ Oct 11 '13 at 11:28
  • Another idea (because I still believe scaladoc doesn't compile) is that you have other compile target on which doc depends, like `test:compile`? Or you have a duplicate class `SigmaDDFactoryImpl`? That is to say, something's wrong with your class path, you might have an older already compiled version of `SigmaDDFactoryImpl` in your dependencies...? Just guessing. – 0__ Oct 11 '13 at 11:29
  • I updated with the whole sbt output. – mundacho Oct 11 '13 at 11:33
  • Well, you should fix the first reported error (`create` cannot be called with that `HashMap`) before thinking about successive errors... – 0__ Oct 11 '13 at 11:37
  • @0__ I found a minimal code that you can use to convince yourself that scaladoc does compile, at least a little bit. I updated my question with that code. – mundacho Oct 11 '13 at 12:20

1 Answers1

0

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.

mundacho
  • 229
  • 1
  • 8
  • 1
    BTW: If you remove the __structural type__ (refined with `sigmaDDFactory`) and write `val inductiveIPFFactory: SigmaDDInductiveIPFFactoryImpl = new SigmaDDInductiveIPFFactoryImpl`, the doc also succeeds. – 0__ Oct 11 '13 at 13:54