Skip to content

Commit

Permalink
Review & rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Nov 27, 2022
1 parent 79aeb2a commit bf8f4fe
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
- java: 11
scala: 2.11.12
- java: 11
scala: 2.12.16
scala: 2.12.17
- java: 11
scala: 2.13.8
scala: 2.13.10
- java: 11
scala: 3.2.1-RC1
scala: 3.2.1
runs-on: ubuntu-latest
env:
SCALAJS_TEST_OPT: full
Expand All @@ -42,7 +42,7 @@ jobs:
sbt -v ++${{ matrix.scala }} scalafmtCheck scalafmtSbtCheck scala_2_11/test:compile scala_2_11/test:doc
sbt -v ++${{ matrix.scala }} scala_2_11/test
;;
2.12.16)
2.12.17)
sbt -v ++${{ matrix.scala }} test:compile test:doc
sbt -v ++${{ matrix.scala }} coverage test coverageReport
sbt -v ++${{ matrix.scala }} coverageAggregate
Expand All @@ -58,7 +58,7 @@ jobs:
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
- name: Upload coverage to Codecov
if: ${{ matrix.scala == '2.12.16' }}
if: ${{ matrix.scala == '2.12.17' }}
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import sbtbuildinfo.BuildInfoPlugin.autoImport._
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}

lazy val scala_2_11Version = "2.11.12"
lazy val scala_2_12Version = "2.12.16"
lazy val scala_2_13Version = "2.13.8"
lazy val scala_3Version = "3.2.1-RC1"
lazy val scala_2_12Version = "2.12.17"
lazy val scala_2_13Version = "2.13.10"
lazy val scala_3Version = "3.2.1"
lazy val scalaVersionsAll =
Seq(scala_2_11Version, scala_2_12Version, scala_2_13Version, scala_3Version)

Expand Down
6 changes: 6 additions & 0 deletions enumeratum-core/src/test/scala/enumeratum/EnumSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class EnumSpec extends AnyFunSpec with Matchers with EnumSpecCompat {
)
)
}

it("should contain instance of subclass") {
import Inheritance._

Word.values should be(IndexedSeq(Word.Hello, Word.Hi))
}
}

describe("#withName") {
Expand Down
13 changes: 13 additions & 0 deletions enumeratum-core/src/test/scala/enumeratum/Models.scala
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,16 @@ object InTheWoods {

}
}

object Inheritance {
sealed trait Word extends EnumEntry

object Word extends Enum[Word] {
sealed class Greeting extends Word

lazy val values = findValues

case object Hello extends Greeting
case object Hi extends Greeting
}
}
13 changes: 7 additions & 6 deletions macros/src/main/scala-3/enumeratum/EnumMacros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ object EnumMacros:
)(using tpe: Type[T]): List[q.reflect.TypeRepr] = {
import q.reflect.*

// TODO: Use SumOf?
given quotes: q.type = q

@annotation.tailrec
Expand Down Expand Up @@ -139,27 +138,30 @@ object EnumMacros:
children: List[Tree],
out: List[TypeRepr]
): List[TypeRepr] = {
val childTpr = children.headOption.collect {
val childTpr: Option[TypeRepr] = children.headOption.collect {
case tpd: Typed =>
tpd.tpt.tpe

case vd: ValDef =>
vd.tpt.tpe

case cd: ClassDef =>
cd.constructor.returnTpt.tpe
cd.symbol.typeRef match {
case TypeRef(tpr, _) =>
tpr.select(cd.symbol)

}
}

childTpr match {
case Some(child) => {
child.asType match {
case '[IsEntry[t]] => {
val tpeSym = child.typeSymbol
// TODO: Check is subtype (same in Scala2?)

if (!isObject(tpeSym)) {
subclasses(children.tail, out)
subclasses(child.typeSymbol.children.map(_.tree) ::: children.tail, out)

} else {
subclasses(children.tail, child :: out)
}
Expand All @@ -177,7 +179,6 @@ object EnumMacros:

tpr.classSymbol
.flatMap { cls =>
// TODO: cls.typeMembers
val types = subclasses(cls.children.map(_.tree), Nil)

if (types.isEmpty) None else Some(types)
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 = 1.7.1
sbt.version = 1.8.0
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")

addSbtPlugin(("org.scoverage" % "sbt-scoverage" % "2.0.2").exclude("org.scala-lang.modules", "*"))
addSbtPlugin(("org.scoverage" % "sbt-scoverage" % "2.0.5").exclude("org.scala-lang.modules", "*"))

addSbtPlugin(("org.scoverage" % "sbt-coveralls" % "1.3.2").exclude("org.scala-lang.modules", "*"))

0 comments on commit bf8f4fe

Please sign in to comment.