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

Skip to content

Add LinkedClass.hasDirectInstances. #4960

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

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ private[emitter] final class ClassEmitter(sjsGen: SJSGen) {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,14 +716,14 @@ final class Emitter[E >: Null <: js.Tree](

if (linkedClass.hasRuntimeTypeInfo) {
main ++= extractWithGlobals(classTreeCache.typeData.getOrElseUpdate(
linkedClass.hasInstances,
linkedClass.hasDirectInstances,
classEmitter.genTypeData(
className, // invalidated by overall class cache (part of ancestors)
kind, // invalidated by class version
linkedClass.superClass, // invalidated by class version
linkedClass.ancestors, // invalidated by overall class cache (identity)
linkedClass.jsNativeLoadSpec, // invalidated by class version
linkedClass.hasInstances // invalidated directly (it is the input to `getOrElseUpdate`)
linkedClass.hasDirectInstances // invalidated directly (it is the input to `getOrElseUpdate`)
)(moduleContext, classCache, linkedClass.pos).map(postTransform(_, 0))))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private[frontend] object BaseLinker {
classDef.pos,
ancestors.toList,
hasInstances = classInfo.isAnySubclassInstantiated,
hasDirectInstances = classInfo.isInstantiated,
hasInstanceTests = classInfo.areInstanceTestsUsed,
hasRuntimeTypeInfo = classInfo.isDataAccessed,
fieldsRead = classInfo.fieldsRead.toSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ final class LinkedClass(
// Actual Linking info
val ancestors: List[ClassName],
val hasInstances: Boolean,
val hasDirectInstances: Boolean,
val hasInstanceTests: Boolean,
val hasRuntimeTypeInfo: Boolean,
val fieldsRead: Set[FieldName],
Expand Down
3 changes: 3 additions & 0 deletions project/BinaryIncompatibilities.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ object BinaryIncompatibilities {
)

val Linker = Seq(
// !!! Breaking, OK in minor release
ProblemFilters.exclude[DirectMissingMethodProblem]("org.scalajs.linker.standard.LinkedClass.this"),

// private, not an issue
ProblemFilters.exclude[DirectMissingMethodProblem]("org.scalajs.linker.standard.CommonPhaseConfig.this"),
)
Expand Down