Skip to content

Commit

Permalink
Merge pull request #56 from eed3si9n/wip/2.13
Browse files Browse the repository at this point in the history
Scala 2.13.0
  • Loading branch information
eed3si9n authored Sep 10, 2019
2 parents 07e0bc9 + 1f05f86 commit 80593c4
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 31 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/scala/treehugger/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions library/src/main/scala/treehugger/NameManglers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions library/src/main/scala/treehugger/treehuggerdsls.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
))
}

Expand Down
2 changes: 1 addition & 1 deletion library/src/test/scala/DSL_1BasicDeclSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion library/src/test/scala/DSL_8StdLibSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()",
"}"
Expand Down
10 changes: 5 additions & 5 deletions library/src/test/scala/TreePrinterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
))
Expand Down Expand Up @@ -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")
)
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.17
sbt.version=0.13.18
2 changes: 1 addition & 1 deletion project/dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 80593c4

Please sign in to comment.