Skip to content

Commit

Permalink
Updated to scala-2.10.1:
Browse files Browse the repository at this point in the history
* fixed case-to-case inheritance error
* got rid of warnings about type erasure in matching
  • Loading branch information
laughedelic committed Jul 21, 2013
1 parent 60f9077 commit 60ea7bc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ startYear := Some(2013)

version := "1.1.0-SNAPSHOT"

scalaVersion := "2.9.3"
scalaVersion := "2.10.1"

scalacOptions ++= Seq(
"-unchecked"
, "-deprecation"
, "-feature"
, "-language:implicitConversions"
)
41 changes: 23 additions & 18 deletions src/main/scala/me/grison/scalocco/Mustache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ case class MustacheParseException(line:Int, msg:String)
value:Any
, childrenString:String
, render:(String)=>String
):Any =
):Any = {
type F1[t] = Function1[String, t]
type F2[t] = Function2[String, Function1[String,String], t]
value match {
case Some(someValue) => eval(someValue, childrenString, render)

Expand All @@ -424,34 +426,37 @@ case class MustacheParseException(line:Int, msg:String)

case m:MapLike[_, _, _] => m

case f:Function1[String, _] =>
case f:F1[_] =>
eval(f(childrenString), childrenString, render)

case f:Function2[String, Function1[String,String], _] =>
case f:F2[_] =>
eval(f(childrenString, render), childrenString, render)

case other => other
}
}

@tailrec
private def findInContext(stack:List[Any], key:String):Any =
stack.headOption match {
case None => None
case Some(head) =>
(head match {
case null => None
case m : MapLike[String,_,_] =>
m.get(key) match {
case Some(v) => v
case None => None
}
case m:Mustache =>
m.globals.get(key) match {
case Some(v) => v
case None => None
}
case any => reflection(any, key)
}) match {
case Some(head) => {
type MapLikeString[a, b] = MapLike[String, a, b]
head match {
case null => None
case m:MapLikeString[_,_] =>
m.get(key) match {
case Some(v) => v
case None => None
}
case m:Mustache =>
m.globals.get(key) match {
case Some(v) => v
case None => None
}
case any => reflection(any, key)
}
} match {
case None => findInContext(stack.tail, key)
case x => x
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/me/grison/scalocco/Scalocco.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object Scalocco extends Markdown {
* Abstract class representing a Scaladoc item.
* @param tpl the Mustache template to be used to render the Scaladoc.
*/
abstract case class DocItem(tpl: Mustache) {
abstract class DocItem(tpl: Mustache) {
// Render this Scaladoc item
def render = tpl.render(this)
}
Expand Down

0 comments on commit 60ea7bc

Please sign in to comment.