Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bacbecf

Browse files
committed
Only set $c_C.prototype.$classData if C has *direct* instances.
It is not useful for classes that only have strict sub instances, i.e., classes that are effectively abstract.
1 parent 4c41798 commit bacbecf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

linker/shared/src/main/scala/org/scalajs/linker/backend/emitter/ClassEmitter.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ private[emitter] final class ClassEmitter(sjsGen: SJSGen) {
826826

827827
def genTypeData(className: ClassName, kind: ClassKind,
828828
superClass: Option[ClassIdent], ancestors: List[ClassName],
829-
jsNativeLoadSpec: Option[JSNativeLoadSpec], hasInstances: Boolean)(
829+
jsNativeLoadSpec: Option[JSNativeLoadSpec], hasDirectInstances: Boolean)(
830830
implicit moduleContext: ModuleContext,
831831
globalKnowledge: GlobalKnowledge, pos: Position): WithGlobals[List[js.Tree]] = {
832832
import TreeDSL._
@@ -847,7 +847,7 @@ private[emitter] final class ClassEmitter(sjsGen: SJSGen) {
847847
val kindOrCtorParam = {
848848
if (isJSType) js.IntLiteral(2)
849849
else if (kind == ClassKind.Interface) js.IntLiteral(1)
850-
else if (kind.isClass && hasInstances) globalVar(VarField.c, className)
850+
else if (kind.isClass && hasDirectInstances) globalVar(VarField.c, className)
851851
else js.IntLiteral(0)
852852
}
853853

linker/shared/src/main/scala/org/scalajs/linker/backend/emitter/Emitter.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -716,14 +716,14 @@ final class Emitter[E >: Null <: js.Tree](
716716

717717
if (linkedClass.hasRuntimeTypeInfo) {
718718
main ++= extractWithGlobals(classTreeCache.typeData.getOrElseUpdate(
719-
linkedClass.hasInstances,
719+
linkedClass.hasDirectInstances,
720720
classEmitter.genTypeData(
721721
className, // invalidated by overall class cache (part of ancestors)
722722
kind, // invalidated by class version
723723
linkedClass.superClass, // invalidated by class version
724724
linkedClass.ancestors, // invalidated by overall class cache (identity)
725725
linkedClass.jsNativeLoadSpec, // invalidated by class version
726-
linkedClass.hasInstances // invalidated directly (it is the input to `getOrElseUpdate`)
726+
linkedClass.hasDirectInstances // invalidated directly (it is the input to `getOrElseUpdate`)
727727
)(moduleContext, classCache, linkedClass.pos).map(postTransform(_, 0))))
728728
}
729729
}

0 commit comments

Comments
 (0)