Skip to content

Commit

Permalink
Updates and fixes for Scala 2.12.0-M2.
Browse files Browse the repository at this point in the history
  • Loading branch information
milessabin committed Jul 20, 2015
1 parent f8c8189 commit 891fd07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -2,7 +2,7 @@ language: scala

scala:
- 2.11.7
- 2.12.0-M1
- 2.12.0-M2

jdk:
- oraclejdk8
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/shapeless/generic.scala
Expand Up @@ -780,7 +780,7 @@ class GenericMacros(val c: whitebox.Context) extends CaseClassMacros {
def to(p: $tpe): Repr = (p match { case ..$toCases }).asInstanceOf[Repr]
def from(p: Repr): $tpe = p match { case ..$fromCases }
}
new $clsName()
new $clsName(): _root_.shapeless.Generic.Aux[$tpe, ${reprTypTree(tpe)}]
"""
}

Expand All @@ -807,7 +807,7 @@ class GenericMacros(val c: whitebox.Context) extends CaseClassMacros {
def to(p: $tpe): Repr = $to
def from(p: Repr): $tpe = _root_.shapeless.Coproduct.unsafeGet(p).asInstanceOf[$tpe]
}
new $clsName()
new $clsName(): _root_.shapeless.Generic.Aux[$tpe, ${reprTypTree(tpe)}]
"""
}

Expand Down
8 changes: 6 additions & 2 deletions core/src/main/scala/shapeless/generic1.scala
Expand Up @@ -207,6 +207,7 @@ class Generic1Macros(val c: whitebox.Context) extends CaseClassMacros {
val tpeTpt = appliedTypTree1(tpe, param1(tpe), nme)
val reprTpt = reprTypTree1(tpe, nme)
val frTpt = mkAttributedRef(frTpe)
val rnme = TypeName(c.freshName)

val clsName = TypeName(c.freshName())
q"""
Expand All @@ -218,7 +219,8 @@ class Generic1Macros(val c: whitebox.Context) extends CaseClassMacros {
def to[$nme](ft: $tpeTpt): R[$nme] = ft match { case ..$toCases }
def from[$nme](rt: R[$nme]): $tpeTpt = rt match { case ..$fromCases }
}
new $clsName()
type $rnme[$nme] = $reprTpt
new $clsName(): _root_.shapeless.Generic1.Aux[$tpe, $frTpe, $rnme]
"""
}

Expand All @@ -237,6 +239,7 @@ class Generic1Macros(val c: whitebox.Context) extends CaseClassMacros {
val tpeTpt = appliedTypTree1(tpe, param1(tpe), nme)
val reprTpt = reprTypTree1(tpe, nme)
val frTpt = mkAttributedRef(frTpe)
val rnme = TypeName(c.freshName)

val to = {
val toCases = ctorsOf1(tpe) zip (Stream from 0) map (mkCoproductCases _).tupled
Expand All @@ -253,7 +256,8 @@ class Generic1Macros(val c: whitebox.Context) extends CaseClassMacros {
def to[$nme](ft: $tpeTpt): R[$nme] = $to
def from[$nme](rt: R[$nme]): $tpeTpt = _root_.shapeless.Coproduct.unsafeGet(rt).asInstanceOf[$tpeTpt]
}
new $clsName()
type $rnme[$nme] = $reprTpt
new $clsName(): _root_.shapeless.Generic1.Aux[$tpe, $frTpe, $rnme]
"""
}
}
Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Expand Up @@ -164,7 +164,7 @@ object ShapelessBuild extends Build {
Seq(
organization := "com.chuusai",
scalaVersion := "2.11.7",
crossScalaVersions := Seq("2.11.7", "2.12.0-M1"),
crossScalaVersions := Seq("2.11.7", "2.12.0-M2"),

(unmanagedSourceDirectories in Compile) <<= (scalaSource in Compile)(Seq(_)),
(unmanagedSourceDirectories in Test) <<= (scalaSource in Test)(Seq(_)),
Expand Down

0 comments on commit 891fd07

Please sign in to comment.