From c7c6f35cc4b1360f13663ef6e8fd1986f2ee710e Mon Sep 17 00:00:00 2001 From: Martin Grotzke Date: Sun, 8 Jan 2023 15:53:51 +0100 Subject: [PATCH] Workaround dotty issue with meta annotations Workaround issue with annotations covered by https://github.com/lampepfl/dotty/issues/12492, fixed with https://github.com/lampepfl/dotty/pull/16445 This commit can be reverted as soon as the fix is released (according to https://github.com/lampepfl/dotty/releases this is not yet the case) --- .../io/ino/solrs/AsyncSolrClientFunSpec.scala | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/test/scala/io/ino/solrs/AsyncSolrClientFunSpec.scala b/src/test/scala/io/ino/solrs/AsyncSolrClientFunSpec.scala index 50c8b58..b0c8276 100644 --- a/src/test/scala/io/ino/solrs/AsyncSolrClientFunSpec.scala +++ b/src/test/scala/io/ino/solrs/AsyncSolrClientFunSpec.scala @@ -8,7 +8,6 @@ import org.apache.solr.client.solrj.beans.Field import org.scalatest.concurrent.Eventually.eventually import org.scalatest.concurrent.PatienceConfiguration.Timeout -import scala.annotation.meta.field import scala.jdk.CollectionConverters._ import scala.concurrent.duration._ @@ -202,9 +201,48 @@ class AsyncSolrClientFunSpec extends StandardFunSpec with RunningSolr { } +/* case class TestBean(@(Field @field) id: String, @(Field @field) name: String, @(Field @field) category: String, @(Field @field) price: Float) { def this() = this(null, null, null, 0) } +*/ + +/* Can be replaced by the version above, once + https://github.com/lampepfl/dotty/issues/12492 respectively https://github.com/lampepfl/dotty/pull/16445 + are released (see https://github.com/lampepfl/dotty/releases) + */ +class TestBean(_id: String, _name: String, _category: String, _price: Float) { + def this() = this(null, null, null, 0) + + @Field + val id: String = _id + @Field + val name: String = _name + @Field + val category: String = _category + @Field + val price: Float = _price + + override def equals(other: Any): Boolean = other match { + case that: TestBean => + id == that.id && + name == that.name && + category == that.category && + price == that.price + case _ => false + } + + override def hashCode(): Int = { + val state = Seq(id, name, category, price) + state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b) + } + +} + +object TestBean { + def apply(id: String, name: String, category: String, price: Float): TestBean = + new TestBean(_id = id, _name = name, _category = category, _price = price) +} \ No newline at end of file