Skip to content

Commit 6e7ea68

Browse files
committed
Fix scala-js/scala-js#4801: Rebase the super JS type as seen from the this type in JS super call.
When doing a super call to a method of a path-dependent JS super class, the `superClass.typeRef` 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. Forward port of the upstream commit scala-js/scala-js@3cef9d0
1 parent e2c456f commit 6e7ea68

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/transform/sjs/ExplicitJSClasses.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,11 @@ class ExplicitJSClasses extends MiniPhase with InfoTransformer { thisPhase =>
637637
private def maybeWrapSuperCallWithContextualJSClassValue(tree: Tree)(using Context): Tree = {
638638
methPart(tree) match {
639639
case Select(sup: Super, _) if isInnerOrLocalJSClass(sup.symbol.asClass.superClass) =>
640-
wrapWithContextualJSClassValue(sup.symbol.asClass.superClass.typeRef)(tree)
640+
val superClass = sup.symbol.asClass.superClass
641+
val jsClassTypeInSuperClass = superClass.typeRef
642+
// scala-js#4801 Rebase the super class type on the current class' this type
643+
val jsClassTypeAsSeenFromThis = jsClassTypeInSuperClass.asSeenFrom(currentClass.thisType, superClass)
644+
wrapWithContextualJSClassValue(jsClassTypeAsSeenFromThis)(tree)
641645
case _ =>
642646
tree
643647
}

0 commit comments

Comments
 (0)