Skip to content

Commit

Permalink
Added debug comments in KebsValueEnumeratum
Browse files Browse the repository at this point in the history
  • Loading branch information
agrodowski committed Sep 15, 2023
1 parent bee33eb commit 1d33f57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ class ValueEnumEntryMacros(override val c: blackbox.Context) extends EnumMacroUt
assertValueEnumEntry(EnumeratumEntry, s"${EnumeratumEntry.typeSymbol} must subclass enumeratum.values.ValueEnumEntry")
val EnumEntry = weakTypeOf[T]

// This works!
// val enumEntrySeq: Seq[ValueEnumLikeEntry[Int]] = LibraryItem.values.map(item =>
// new ValueEnumLikeEntry[Int] {
// override def value: Int = item.value
// })
// println(enumEntrySeq)


// And this does not work
val ValueType = weakTypeOf[ValueType]
c.Expr[ValueEnumOf[ValueType, T]](
q"""
Expand All @@ -50,3 +41,21 @@ class ValueEnumEntryMacros(override val c: blackbox.Context) extends EnumMacroUt
)
}
}

// This works!
// val enumEntrySeq: Seq[ValueEnumLikeEntry[Int]] = LibraryItem.values.map(item =>
// new ValueEnumLikeEntry[Int] {
// override def value: Int = item.value
// })
// println(enumEntrySeq)


// And this does not compile. I think there's something wrong with EnumeratumEntry usage since when there is
// q"""
// new _root_.pl.iterators.kebs.enumeratum.ValueEnumOf[${ValueType}, ${EnumEntry}](
// new _root_.pl.iterators.kebs.enums.ValueEnumLike[${ValueType}, ${EnumEntry}] {
// override def values: Seq[$EnumEntry] = null
// }
// )
// """
// it compiles and the test just fails (but without any errors).
1 change: 1 addition & 0 deletions enumeratum/src/test/scala-2/ValueEnumeratumTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MyValueEnumTest extends AnyFunSuite with Matchers {

val valueEnumOf: ValueEnumOf[Int, ValueEnumLikeEntry[Int]] = implicitly[ValueEnumOf[Int, ValueEnumLikeEntry[Int]]]

// It works but analogical code in quasiquote in KebsValueEnumeratum does not compile. Why?
val enumEntrySeq: Seq[ValueEnumLikeEntry[Int]] = LibraryItem.values.map(item =>
new ValueEnumLikeEntry[Int] {
override def value: Int = item.value
Expand Down

0 comments on commit 1d33f57

Please sign in to comment.