使用Binding.scala宏注释时如何抑制编辑器中的intellij IDEA错误? [英] How to suppress intellij IDEA error in editor when using Binding.scala macro annotation?

查看:318
本文介绍了使用Binding.scala宏注释时如何抑制编辑器中的intellij IDEA错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管它在sbt控制台中编译和运行。
Intellij抱怨说我应该在编辑器中使用Binding [Node]而不是Elem。

  @dom def renderDiv:Binding [Div] =< div> ...< / div>从intellij IDEA的角度来看,此方法返回一个 Elem 它是 scala.xml.Node 
的子类型,但呈现时:

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

它需要一个 org.scalajs.dom.raw.Node



有什么解决方法吗?

解决方案

可以将隐式转换def放在范围内:

  package object xxx {
implicit def makeIntellijHappy [T<:org.scalajs.dom.raw.Node](x:scala.xml.Node):Binding [T] =
抛出新的AssertionError(这不应该执行)
}

定义方法以上的包装对象,因此它涵盖了整个包装。实际上这个方法永远不会被执行。


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?

解决方案

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.

这篇关于使用Binding.scala宏注释时如何抑制编辑器中的intellij IDEA错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆