Skip to content

Methods exported under a scalac name starting with $ are not exported #3219

@sjrd

Description

@sjrd
import scala.scalajs.js.annotation._

@JSExportTopLevel("Functions")
object Functions {
  @JSExport("$a")
  def f(x: Int): Int = x

  @JSExport
  def +(x: Int): Int = x

  @JSExport("-")
  def plus(x: Int): Int = x

  // OK
  @JSExport("plus")
  def ++(x: Int): Int = x
}

Only the last function is actually exported. All the other ones vanish. The problem is already apparent in the IR:

> scalajsp Functions$.sjsir
module class LFunctions$ extends O {
  def f__I__I(x: int): int = {
    x
  }
  def $$plus__I__I(x: int): int = {
    x
  }
  def plus__I__I(x: int): int = {
    x
  }
  def $$plus$plus__I__I(x: int): int = {
    x
  }
  def $$js$exported$meth$$a__I__O(x: int): any = {
    this.f__I__I(x)
  }
  def $$js$exported$meth$$plus__I__O(x: int): any = {
    this.$$plus__I__I(x)
  }
  def $$js$exported$meth$$minus__I__O(x: int): any = {
    this.plus__I__I(x)
  }
  def $$js$exported$meth$plus__I__O(x: int): any = {
    this.$$plus$plus__I__I(x)
  }
  def init___() {
    this.O::init___();
    mod:LFunctions$<-this
  }
  def "plus"(arg$1: any): any = {
    val prep0: int = arg$1.asInstanceOf[I];
    this.$$js$exported$meth$plus__I__O(prep0)
  }
  export top module "Functions"
}

Metadata

Metadata

Assignees

Labels

bugConfirmed bug. Needs to be fixed.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions