How to suppress intellij IDEA error in editor when using Binding.scala macro annotation?

坚强是说给别人听的谎言 提交于 2019-12-14 02:08:24

问题


Despite it compiles and runs in sbt console. Intellij complains that I should have Binding[Node] instead of Elem in editor.

@dom def renderDiv: Binding[Div] = <div>...</div>

From intellij IDEA's perspective, this method returns a Elem which is a subtype of scala.xml.Node, but when rendering:

dom.render(document.getElementById("root"),renderDiv)

it requires a org.scalajs.dom.raw.Node.

Is there any workaround to this?


回答1:


Could put an implicit conversion def in scope:

package object xxx {
  implicit def makeIntellijHappy[T<:org.scalajs.dom.raw.Node](x: scala.xml.Node): Binding[T] =
    throw new AssertionError("This should never execute.")
}

define method above in the package object, thus it covers the whole package. This method will never be executed, actually.



来源:https://stackoverflow.com/questions/42617401/how-to-suppress-intellij-idea-error-in-editor-when-using-binding-scala-macro-ann

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!