8000 Compiler crashes on nested JS class with default constructor params with private companion · Issue #4526 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content
Compiler crashes on nested JS class with default constructor params with private companion #4526
Closed
@gzm0

Description

@gzm0
package helloworld

import scala.scalajs.js
import js.annotation._

class A {
  class B(x: Int = 1) extends js.Object

  private object B
}

object HelloWorld {
  def main(args: Array[String]): Unit = {
    val a = new A
    val x = new a.B()
    println(x)
  }
}

Crashes:

[info] compiling 1 Scala source to /home/tos/gh/scala-js/examples/helloworld/.2.12/target/scala-2.12/classes ...
[error] Error while emitting HelloWorld.scala
[error] assertion failed: 
[error]   need default getter for method helloworld.A$B.<init>
[error]      while compiling: /home/tos/gh/scala-js/examples/helloworld/src/main/scala/helloworld/HelloWorld.scala
[error]         during phase: jscode
[error]      library version: version 2.12.14
[error]     compiler version: version 2.12.14
[error]   reconstructed args: -bootclasspath /home/tos/.sbt/boot/scala-2.12.14/lib/scala-library.jar -deprecation -encoding utf8 -feature -unchecked -Xfatal-warnings -Wconf:cat=feature:w -Wconf:cat=unchecked:w -Wconf:cat=deprecation:w -Wconf:cat=deprecation:ws -Wconf:cat=feature:ws -Wconf:cat=optimizer:ws -classpath /home/tos/gh/scala-js/examples/helloworld/.2.12/target/scala-2.12/classes:/home/tos/gh/scala-js/library/.2.12/target/scala-2.12/scalajs-library_2.12-1.7.0-SNAPSHOT.jar -Xplugin:/home/tos/gh/scala-js/compiler/.2.12/target/scala-2.12/scalajs-compiler_2.12.14-1.7.0-SNAPSHOT.jar
[error] 
[error]   last tree to typer: TypeTree(class A$B)
[error]        tree position: line 20 of /home
6B6C
/tos/gh/scala-js/examples/helloworld/src/main/scala/helloworld/HelloWorld.scala
[error]             tree tpe: helloworld.A$B
[error]               symbol: class A$B in package helloworld
[error]    symbol definition: class A$B extends Object (a ClassSymbol)
[error]       symbol package: helloworld
[error]        symbol owners: class A$B
[error]            call site: object A$B in package helloworld in package helloworld
[error] 
[error] == Source file context for tree position ==
[error] 
[error]     17 object HelloWorld {
[error]     18   def main(args: Array[String]): Unit = {
[error]     19     val a = new A
[error]     20     val x = new a.B()
[error]     21     println(x)
[error]     22   }
[error]     23 }
[error] one error found
[error] (helloworld2_12 / Compile / compileIncremental) Compilation failed
[error] Total time: 1 s, completed Jul 10, 2021, 11:50:45 AM

This assertion triggers:

assert(defaultGetter.exists,
s"need default getter for method ${sym.fullName}")

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

    0