Skip to content

Commit c7c6f35

Browse files
committed
Workaround dotty issue with meta annotations
Workaround issue with annotations covered by scala/scala3#12492, fixed with scala/scala3#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)
1 parent 4ea2356 commit c7c6f35

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

src/test/scala/io/ino/solrs/AsyncSolrClientFunSpec.scala

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import org.apache.solr.client.solrj.beans.Field
88
import org.scalatest.concurrent.Eventually.eventually
99
import org.scalatest.concurrent.PatienceConfiguration.Timeout
1010

11-
import scala.annotation.meta.field
1211
import scala.jdk.CollectionConverters._
1312
import scala.concurrent.duration._
1413

@@ -202,9 +201,48 @@ class AsyncSolrClientFunSpec extends StandardFunSpec with RunningSolr {
202201

203202
}
204203

204+
/*
205205
case class TestBean(@(Field @field) id: String,
206206
@(Field @field) name: String,
207207
@(Field @field) category: String,
208208
@(Field @field) price: Float) {
209209
def this() = this(null, null, null, 0)
210210
}
211+
*/
212+
213+
/* Can be replaced by the version above, once
214+
https://github.com/lampepfl/dotty/issues/12492 respectively https://github.com/lampepfl/dotty/pull/16445
215+
are released (see https://github.com/lampepfl/dotty/releases)
216+
*/
217+
class TestBean(_id: String, _name: String, _category: String, _price: Float) {
218+
def this() = this(null, null, null, 0)
219+
220+
@Field
221+
val id: String = _id
222+
@Field
223+
val name: String = _name
224+
@Field
225+
val category: String = _category
226+
@Field
227+
val price: Float = _price
228+
229+
override def equals(other: Any): Boolean = other match {
230+
case that: TestBean =>
231+
id == that.id &&
232+
name == that.name &&
233+
category == that.category &&
234+
price == that.price
235+
case _ => false
236+
}
237+
238+
override def hashCode(): Int = {
239+
val state = Seq(id, name, category, price)
240+
state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b)
241+
}
242+
243+
}
244+
245+
object TestBean {
246+
def apply(id: String, name: String, category: String, price: Float): TestBean =
247+
new TestBean(_id = id, _name = name, _category = category, _price = price)
248+
}

0 commit comments

Comments
 (0)