Closed
Description
Compiler version
3.2.0
Minimized code
import scala.scalajs.js
@js.annotation.JSGlobal("a")
@js.native
def string: String = js.native // ok
@js.annotation.JSGlobal("a")
@js.native
def a: "a" = js.native // error: The type of a must be explicitly specified because it is JS native.
// same with `var`/`val`
Output
The type of a must be explicitly specified because it is JS native.
Expectation
The type is specified, so it should be accepted.
I see this in the implementation of the check:
if (tree.tpt.span.isSynthetic)
report.error(i"The type of ${tree.name} must be explicitly specified because it is JS native.", tree)
Perhaps it is the case that the literal type tree is considered synthetic somehow?