For Example:
object CampaignTypes extends Enumeration {
type CampaignType = Value
val ABC,DEF = Value
}
object campaignTypeId extends EnumNameField(this, CampaignTypes) {
override val defaultValue = CampaignTypes.ABC
}
IntelliJ underlines CampaignTypes.ABC in red with message Expression of type CampaignTypes.Value doesn't conform to expected type EnumType#Value
The code compiles & works. But, IntelliJ marks it as an error, making it difficult to read code (as there are many other cases, which is also not resolved by IntelliJ). The right Scala plugin is also used. Is there a way to resolve this?
Another example w.r.t methods defined on a BsonRecord
sealed trait Product {...}
class Document extends BsonRecord[Document] {
object productType extends StringField(this, 20)
....
def toTyped: Option[Product] = this.productType.get match {//something which returns an Option[Product] from a List[Product]}
}
object documents extends BsonRecordListField(this, Document) {
def toProducts: Set[Product] =
this.get.flatMap(_.toTyped)(breakOut) //Cannot resolve symbol toTyped
}
Yes, you can help Intellij by providing type hints :
where
A
is the type of the encapsulating class/objectFor a general solution :
For BsonRecordListField, expliciting generic types should solve it too.