diff --git a/.travis.yml b/.travis.yml index d536538..73f1218 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,20 +2,18 @@ sudo: false language: scala +jdk: openjdk8 + script: - sbt "++${TRAVIS_SCALA_VERSION}" "${SBT_CMD}" matrix: include: - env: SBT_CMD="test" - jdk: openjdk6 scala: 2.10.7 - env: SBT_CMD="test" - jdk: openjdk6 scala: 2.11.12 - env: SBT_CMD="test" - jdk: oraclejdk8 scala: 2.12.6 - env: SBT_CMD="test" - jdk: oraclejdk8 - scala: 2.13.0-M4 + scala: 2.13.0 diff --git a/build.sbt b/build.sbt index f2f897d..d8192de 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ val commonSettings = Seq( organization := "com.eed3si9n", version := "0.4.4-SNAPSHOT", scalaVersion := "2.11.12", - crossScalaVersions := Seq("2.12.6", "2.13.0-M4", "2.11.12", "2.10.7"), + crossScalaVersions := Seq("2.12.9", "2.13.0", "2.11.12", "2.10.7"), homepage := Some(url("http://eed3si9n.com/treehugger")), licenses := Seq("MIT License" -> url("http://www.opensource.org/licenses/mit-license.php")), description := "a library to code Scala programmatically.", diff --git a/library/src/main/scala/treehugger/Definitions.scala b/library/src/main/scala/treehugger/Definitions.scala index b455b64..529858e 100644 --- a/library/src/main/scala/treehugger/Definitions.scala +++ b/library/src/main/scala/treehugger/Definitions.scala @@ -29,7 +29,7 @@ trait Definitions extends api.StandardDefinitions { self: Forest => ) private def classesMap[T](f: Name => T) = symbolsMap(ScalaValueClassesNoUnit, f) - private def symbolsMap[T](syms: List[Symbol], f: Name => T): Map[Symbol, T] = syms zip (syms map (x => f(x.name))) toMap + private def symbolsMap[T](syms: List[Symbol], f: Name => T): Map[Symbol, T] = (syms zip (syms map (x => f(x.name)))).toMap private def symbolsMapFilt[T](syms: List[Symbol], p: Name => Boolean, f: Name => T) = symbolsMap(syms filter (x => p(x.name)), f) lazy val numericWeight = symbolsMapFilt(ScalaValueClasses, nameToWeight.keySet, nameToWeight) diff --git a/library/src/main/scala/treehugger/NameManglers.scala b/library/src/main/scala/treehugger/NameManglers.scala index a4b04ad..4419ae9 100644 --- a/library/src/main/scala/treehugger/NameManglers.scala +++ b/library/src/main/scala/treehugger/NameManglers.scala @@ -46,7 +46,7 @@ trait NameManglers { self: Forest => val cs = s.toArray val bytes = Codec.toUTF8(s).array md5 update bytes - val md5chars = md5.digest() map (b => (b & 0xFF).toHexString) mkString + val md5chars = (md5.digest() map (b => (b & 0xFF).toHexString)).mkString prefix + marker + md5chars + marker + suffix } @@ -128,14 +128,14 @@ trait NameManglers { self: Forest => def getterName(name: TermName): TermName = if (isLocalName(name)) localToGetter(name) else name def getterToLocal(name: TermName): TermName = name.toTermName append LOCAL_SUFFIX_STRING def getterToSetter(name: TermName): TermName = name.toTermName append SETTER_SUFFIX - def localToGetter(name: TermName): TermName = name stripEnd LOCAL_SUFFIX_STRING toTermName + def localToGetter(name: TermName): TermName = (name stripEnd LOCAL_SUFFIX_STRING).toTermName def setterToGetter(name: TermName): TermName = { val p = name.pos(TRAIT_SETTER_SEPARATOR_STRING) if (p < name.length) setterToGetter(name.subName(p + TRAIT_SETTER_SEPARATOR_STRING.length, name.length)) else - name stripEnd SETTER_SUFFIX toTermName + (name stripEnd SETTER_SUFFIX).toTermName } def defaultGetterName(name: Name, pos: Int): TermName = { @@ -165,10 +165,10 @@ trait NameManglers { self: Forest => /** Note that for performance reasons, stripEnd does not verify that the * suffix is actually the suffix specified. */ - def dropSingletonName(name: Name): TypeName = name stripEnd SINGLETON_SUFFIX toTypeName - def singletonName(name: Name): TypeName = name append SINGLETON_SUFFIX toTypeName - def implClassName(name: Name): TypeName = name append IMPL_CLASS_SUFFIX toTypeName - def interfaceName(implname: Name): TypeName = implname stripEnd IMPL_CLASS_SUFFIX toTypeName + def dropSingletonName(name: Name): TypeName = (name stripEnd SINGLETON_SUFFIX).toTypeName + def singletonName(name: Name): TypeName = (name append SINGLETON_SUFFIX).toTypeName + def implClassName(name: Name): TypeName = (name append IMPL_CLASS_SUFFIX).toTypeName + def interfaceName(implname: Name): TypeName = (implname stripEnd IMPL_CLASS_SUFFIX).toTypeName def localDummyName(clazz: Symbol): TermName = newTermName(LOCALDUMMY_PREFIX + clazz.name + ">") def productAccessorName(i: Int): TermName = newTermName("_" + i) def superName(name: Name): TermName = newTermName(SUPER_PREFIX_STRING + name) diff --git a/library/src/main/scala/treehugger/treehuggerdsls.scala b/library/src/main/scala/treehugger/treehuggerdsls.scala index 88a06fc..8b06083 100644 --- a/library/src/main/scala/treehugger/treehuggerdsls.scala +++ b/library/src/main/scala/treehugger/treehuggerdsls.scala @@ -635,18 +635,18 @@ trait TreehuggerDSLs { self: Forest => def bounds: Tree = if (_bounds.isEmpty) EmptyTree else TypeTree(TypeBounds( - (_bounds collect { + ((_bounds collect { case LowerTypeBoundsStart(lo) => lo - } headOption) getOrElse(NothingClass.tpe), - (_bounds collect { + }).headOption).getOrElse(NothingClass.tpe), + ((_bounds collect { case UpperTypeBoundsStart(hi) => hi - } headOption) getOrElse(NothingClass.tpe), - (_bounds collect { + }).headOption).getOrElse(NothingClass.tpe), + ((_bounds collect { case ViewBoundsStart(trg) => trg - } headOption) getOrElse(NothingClass.tpe), - (_bounds collect { + }).headOption).getOrElse(NothingClass.tpe), + ((_bounds collect { case ContextBoundsStart(typcon) => typcon - } headOption) getOrElse(NothingClass.tpe) + }).headOption).getOrElse(NothingClass.tpe) )) } diff --git a/library/src/test/scala/DSL_1BasicDeclSpec.scala b/library/src/test/scala/DSL_1BasicDeclSpec.scala index 899d7a5..10c22d8 100644 --- a/library/src/test/scala/DSL_1BasicDeclSpec.scala +++ b/library/src/test/scala/DSL_1BasicDeclSpec.scala @@ -155,7 +155,7 @@ limit them to some members. $i def function2 = ((DEF("put", UnitClass) withParams(PARAM("x", IntClass)): Tree) must print_as("def put(x: Int): Unit")) and ((DEF(sym.run, UnitClass) withParams(PARAM("x", IntClass) := LIT(0)): Tree) must print_as("def run(x: Int = 0): Unit")) and - ((DEF("sideEffect", UnitClass) withParams()).tree must print_as("def sideEffect(): Unit")) + ((DEF("sideEffect", UnitClass).withParams()).tree must print_as("def sideEffect(): Unit")) def function3 = (DEF("compare", BooleanClass) diff --git a/library/src/test/scala/DSL_8StdLibSpec.scala b/library/src/test/scala/DSL_8StdLibSpec.scala index 3cfaabb..79fc555 100644 --- a/library/src/test/scala/DSL_8StdLibSpec.scala +++ b/library/src/test/scala/DSL_8StdLibSpec.scala @@ -124,7 +124,7 @@ class DSL_8StdLibSpec extends DSLSpec { def is = s2 def traversable1 = (REF("foo") FOREACH LAMBDA(PARAM("x")) ==> BLOCK( - REF("x") APPLY())) must print_as( + REF("x").APPLY())) must print_as( "foo foreach { x =>", " x()", "}" diff --git a/library/src/test/scala/TreePrinterSpec.scala b/library/src/test/scala/TreePrinterSpec.scala index 800dffa..3e95118 100644 --- a/library/src/test/scala/TreePrinterSpec.scala +++ b/library/src/test/scala/TreePrinterSpec.scala @@ -69,14 +69,14 @@ class TreePrinterSpec extends DSLSpec { def is = sequential ^ val tree = (OBJECTDEF(ChecksumAccumulator) := BLOCK( VAL(cache) withFlags(Flags.PRIVATE) := - mutableMapType(StringClass, IntClass) APPLY (), + mutableMapType(StringClass, IntClass).APPLY(), DEF("calculate", IntClass) withParams(PARAM(s, StringClass)) := (IF(REF(cache) DOT "contains" APPLY REF(s)) THEN REF(cache).APPLY(REF(s)) ELSE BLOCK( VAL("acc") := NEW(ChecksumAccumulator), FOR(VALFROM("c") := REF(s)) DO (REF("acc") DOT "add" APPLY (REF("c") DOT "toByte")), - VAL("cs") := REF("acc") DOT "checksum" APPLY (), + VAL("cs") := REF("acc").DOT("checksum").APPLY(), REF(cache) INFIX ("+=") APPLY REF(s) INFIX ("->") APPLY REF("cs"), REF("cs") )) @@ -118,7 +118,7 @@ class TreePrinterSpec extends DSLSpec { def is = sequential ^ VAL(buf) withFlags(Flags.PRIVATE) := NEW(ArrayBufferClass TYPE_OF IntClass), DEF("get", IntClass) := - REF(buf) DOT "remove" APPLY(), + REF(buf).DOT("remove").APPLY(), PROC("put") withParams(PARAM("x", IntClass)) := BLOCK( REF(buf) INFIX("+=") APPLY REF("x") ) @@ -192,8 +192,8 @@ class TreePrinterSpec extends DSLSpec { def is = sequential ^ withTypeParams(TYPEVAR(T) UPPER TYPE_ORDERED(T)) withParams(PARAM("elements", TYPE_LIST(T))) := REF("elements") MATCH( - CASE(ListClass UNAPPLY()) ==> THROW(IllegalArgumentExceptionClass, "empty list!"), - CASE(ListClass UNAPPLY(ID("x"))) ==> REF("x"), + CASE(ListClass.UNAPPLY()) ==> THROW(IllegalArgumentExceptionClass, "empty list!"), + CASE(ListClass.UNAPPLY(ID("x"))) ==> REF("x"), CASE(ID("x") LIST_:: ID("rest")) ==> BLOCK( VAL("maxRest") := maxListUpBound APPLY(REF("rest")), IF(REF("x") INT_> REF("maxRest")) THEN REF("x") diff --git a/project/build.properties b/project/build.properties index 133a8f1..8e682c5 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.17 +sbt.version=0.13.18 diff --git a/project/dependencies.scala b/project/dependencies.scala index dab08e9..87f6491 100644 --- a/project/dependencies.scala +++ b/project/dependencies.scala @@ -3,7 +3,7 @@ import Keys._ object Dependencies { def specs2(sv: String) = sv match { - case x if x startsWith "2.13." => List("org.specs2" %% "specs2-core" % "4.3.0" % Test) + case x if x startsWith "2.13." => List("org.specs2" %% "specs2-core" % "4.7.0" % Test) case _ => List("org.specs2" %% "specs2-core" % "3.9.5" % Test) }