diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-03 01:48:36 +0000 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-03 01:48:36 +0000 |
commit | 00a4189b589d6ba263cedda18349b54fee147ed1 (patch) | |
tree | 71ba409047e7d13af90e9b7cb917df8216f7d192 /stage2 | |
parent | 5b6f9f6e69fa15e1a731ec689e00ffdd9d139a9d (diff) | |
download | cbt-00a4189b589d6ba263cedda18349b54fee147ed1.tar.gz cbt-00a4189b589d6ba263cedda18349b54fee147ed1.tar.bz2 cbt-00a4189b589d6ba263cedda18349b54fee147ed1.zip |
fix trying to access non-existent methods of Unit not erroring
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/Lib.scala | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 3f6a92e..5b6a709 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -159,16 +159,15 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){ members.headOption.map{ taskName => logger.lib("Calling task " ++ taskName.toString) taskMethods(obj.getClass).get(taskName).map{ method => - Option(method.invoke(obj) /* null in case of Unit */ ).map{ result => - result match { - case code if code.getClass.getSimpleName == "ExitCode" => - // FIXME: ExitCode needs to be part of the compatibility interfaces - Seq((None, Some(ExitCode(Stage0Lib.get(code,"integer").asInstanceOf[Int])), None)) - case bs: Seq[_] if bs.size > 0 && bs.forall(_.isInstanceOf[BaseBuild]) => - bs.flatMap( b => callInternal(b.asInstanceOf[BaseBuild], members.tail, previous :+ taskName, context) ) - case _ => callInternal(result, members.tail, previous :+ taskName, context) - } - }.getOrElse( Seq( (None, None, None) ) ) + Option(method.invoke(obj) /* null in case of Unit */ ).getOrElse(().asInstanceOf[AnyRef]) match { + case code if code.getClass.getSimpleName == "ExitCode" => + // FIXME: ExitCode needs to be part of the compatibility interfaces + Seq((None, Some(ExitCode(Stage0Lib.get(code,"integer").asInstanceOf[Int])), None)) + case bs: Seq[_] if bs.size > 0 && bs.forall(_.isInstanceOf[BaseBuild]) => + bs.flatMap( b => callInternal(b.asInstanceOf[BaseBuild], members.tail, previous :+ taskName, context) ) + case result => + callInternal(result, members.tail, previous :+ taskName, context) + } }.getOrElse{ val folder = NameTransformer.decode(taskName) if( context != null && (context.workingDirectory / folder).exists ){ @@ -182,7 +181,7 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){ newContext ) } else { - Seq( ( Some(obj), None, Some("\nMethod not found: " ++ (previous :+ taskName).mkString(".") ++ "\n") ) ) + Seq( ( Some(obj), None, Some("Object " ++ previous.mkString(".") ++ s" has no method $taskName\n") ) ) } } }.getOrElse{ |