Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegating to the implementation of a calculated super class causes Internal error #4801

Closed
gzm0 opened this issue Jan 25, 2023 · 4 comments
Closed
Assignees
Labels
bug Confirmed bug. Needs to be fixed.
Milestone

Comments

@gzm0
Copy link
Contributor

gzm0 commented Jan 25, 2023

@js.native
trait OuterNativeTrait_Issue4402 extends js.Object {
  @js.native
  class InnerClass extends js.Object {
    def foo(): Unit = js.native
  }
}

object Mytest {
  def createSubclass(superclass: js.Function) = {
    val outer = js.Dynamic.literal(InnerClass = superclass).asInstanceOf[OuterNativeTrait_Issue4402]

    class Subclass extends outer.InnerClass {
      override def foo(): Unit = super.foo()
    }
  }
}

Fails with

scala-js/examples/helloworld/src/main/scala/helloworld/HelloWorld.scala:24:20: Internal error: unable to find the outer accessor symbol of class Subclass
      override def foo(): Unit = super.foo()
                   ^
@gzm0 gzm0 added the bug Confirmed bug. Needs to be fixed. label Jan 25, 2023
@gzm0
Copy link
Contributor Author

gzm0 commented Jan 25, 2023

@gzm0
Copy link
Contributor Author

gzm0 commented Jan 25, 2023

@sjrd
Copy link
Member

sjrd commented Jan 26, 2023

As a workaround, it's probably possible to refer to the parent class prototype to do an old style super call:

override def foo(): Unit =
  superclass.asInstanceOf[js.Dynamic].prototype.foo.call(this)

@ebruchez
Copy link

The workaround works, thanks.

sjrd added a commit to sjrd/scala-js that referenced this issue Jan 27, 2023
…e in JS super call.

When doing a super call to a method of a path-dependent JS super
class, the `superClass.tpe_*` is only valid as seen from the
super class' thisType. We need to rebase it with `asSeenFrom` to
be in the context of the current class' thisType.
sjrd added a commit to sjrd/scala-js that referenced this issue Jan 28, 2023
…e in JS super call.

When doing a super call to a method of a path-dependent JS super
class, the `superClass.tpe_*` is only valid as seen from the
super class' thisType. We need to rebase it with `asSeenFrom` to
be in the context of the current class' thisType.
@gzm0 gzm0 closed this as completed in 3cef9d0 Jan 31, 2023
gzm0 added a commit that referenced this issue Jan 31, 2023
…s-class

Fix #4801: Rebase the super JS type as seen from the this type in JS super call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug. Needs to be fixed.
Projects
None yet
Development

No branches or pull requests

3 participants