"scala is not a closing class"

When compiling this specification:

import org.specs.Specification import org.specs.matcher.extension.ParserMatchers class ParserSpec extends Specification with ParserMatchers { type Elem = Char "Vaadin DSL parser" should { "parse attributes in parentheses" in { DslParser.attributes must( succeedOn(stringReader("""(attr1="val1")""")). withResult(Map[String, AttrVal]("attr1" -> AttrVal("val1", "String")))) } } } 

I get the following error:

 ParserSpec.scala:21 error: scala is not an enclosing class withResult(Map[String, AttrVal]("attr1" -> AttrVal("val1", "String")))) ^ 

I don’t understand the error message at all. Why can he appear?

Scala version 2.8.1, version version 1.6.7.2.

DslParser.attributes is of type Parser[Map[String, AttrVal]] , and the succeedOn and withResult defined as follows:

 trait ParserMatchers extends Parsers with Matchers { case class SucceedOn[T](str: Input, resultMatcherOpt: Option[Matcher[T]]) extends Matcher[Parser[T]] { def apply(parserBN: => Parser[T]) = { val parser = parserBN val parseResult = parser(str) parseResult match { case Success(result, remainingInput) => val succParseMsg = "Parser "+parser+" succeeded on input "+str+" with result "+result val okMsgBuffer = new StringBuilder(succParseMsg) val koMsgBuffer = new StringBuilder(succParseMsg) val cond = resultMatcherOpt match { case None => true case Some(resultMatcher) => resultMatcher(result) match { case (success, okMessage, koMessage) => okMsgBuffer.append(" and ").append(okMessage) koMsgBuffer.append(" but ").append(koMessage) success } } (cond, okMsgBuffer.toString, koMsgBuffer.toString) case _ => (false, "Parser succeeded", "Parser "+parser+": "+parseResult) } } def resultMust(resultMatcher: Matcher[T]) = this.copy(resultMatcherOpt = Some(resultMatcher)) def withResult(expectedResult: T) = resultMust(beEqualTo(expectedResult)) def ignoringResult = this.copy(resultMatcherOpt = None) } def succeedOn[T](str: Input, expectedResultOpt: Option[Matcher[T]] = None) = SucceedOn(str, expectedResultOpt) implicit def stringReader(str: String): Reader[Char] = new CharSequenceReader(str) } 
+6
scala specs
source share
1 answer

This message may occur when the compiler is really trying to signal a type error or a type inference error. This is a bug (or bug family) in scalac.

To find the problem, gradually add explicit and argument types; break complex expressions into smaller subexpressions.

For bonus points, create a separate example and write a mistake.

+8
source share

All Articles