2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【メモ】Realm+KotlinでequalToメソッドがコンパイルエラーになる時の対処

Last updated at Posted at 2017-12-16

メモ書きです。
AndroidStudio3への移行に併せて各種ライブラリを最新版にしたら色々と罠を踏みました

環境

バージョン
Android Studio 3.0.1
Realm 4.3.1
kotlin 1.2.10

現象

test.kt
Realm.where(hoge::class.java).equalTo("field", 0)

と普通にequalToを使っているだけなのに、

Error:(260, 30) Overload resolution ambiguity:
public open fun notEqualTo(p0: String!, @Nullable p1: Int?): RealmQuery<MaterialMaster!>! defined in io.realm.RealmQuery

とか言われる。

解決法

test.kt
Realm.where(hoge::class.java).equalTo("field", 0.toInt())

はい。00.toInt()に変えただけです。
えー。Realmの中の人曰く、Kotlinのコンパイラのバグっぽい。

ちなみにnotEqualTo、Byte、Long、Shortでも同様の現象が起きます。
解決方法は一緒です。

参考

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?