From 1d33f57d34fe955deeb0ee9b6999526bc2bc7cea Mon Sep 17 00:00:00 2001 From: agrodowski Date: Fri, 15 Sep 2023 13:15:49 +0200 Subject: [PATCH] Added debug comments in KebsValueEnumeratum --- .../kebs/enumeratum/KebsValueEnumeratum.scala | 27 ++++++++++++------- .../test/scala-2/ValueEnumeratumTest.scala | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/enumeratum/src/main/scala-2/pl/iterators/kebs/enumeratum/KebsValueEnumeratum.scala b/enumeratum/src/main/scala-2/pl/iterators/kebs/enumeratum/KebsValueEnumeratum.scala index b25084ff..a3808ca5 100644 --- a/enumeratum/src/main/scala-2/pl/iterators/kebs/enumeratum/KebsValueEnumeratum.scala +++ b/enumeratum/src/main/scala-2/pl/iterators/kebs/enumeratum/KebsValueEnumeratum.scala @@ -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""" @@ -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). diff --git a/enumeratum/src/test/scala-2/ValueEnumeratumTest.scala b/enumeratum/src/test/scala-2/ValueEnumeratumTest.scala index e3f39a81..1542cfc0 100644 --- a/enumeratum/src/test/scala-2/ValueEnumeratumTest.scala +++ b/enumeratum/src/test/scala-2/ValueEnumeratumTest.scala @@ -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