Skip to content

Commit 9f6d249

Browse files
committed
Scala.js: Do not emit reflective instantiation data for local classes.
1 parent 017686c commit 9f6d249

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
733733
// used to populate the EnclosingMethod attribute.
734734
// it is very tricky in presence of classes(and annonymous classes) defined inside supper calls.
735735
if (sym.exists) {
736+
/* Part of this logic duplicates originalOwner in SymDenotations, but it cannot
737+
* easily be factored out because we need the `shiftedContext` when calling
738+
* `lexicallyEnclosingClass`
739+
*/
736740
val original = toDenot(sym).initial
737741
val validity = original.validFor
738742
val shiftedContext = ctx.withPhase(validity.phaseId)

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,8 @@ class JSCodeGen()(implicit ctx: Context) {
512512
genRegisterReflectiveInstantiationForModuleClass(sym)
513513
else if (sym.is(ModuleClass))
514514
None // scala-js#3228
515-
// TODO What is `originalOwner` in dotc?
516-
//else if (sym.is(Lifted) && !sym.originalOwner.isClass)
517-
// None // scala-js#3227
515+
else if (sym.is(Lifted) && !sym.originalOwner.isClass)
516+
None // scala-js#3227
518517
else
519518
genRegisterReflectiveInstantiationForNormalClass(sym)
520519
}

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,15 @@ object SymDenotations {
399399
/** The name with which the denoting symbol was created */
400400
final def originalName(implicit ctx: Context): Name = initial.effectiveName
401401

402+
/** The owner with which the denoting symbol was created. */
403+
final def originalOwner(implicit ctx: Context): Symbol =
404+
if (exists) {
405+
// In part duplicated in DottyBackendInterface.originalLexicallyEnclosingClass (see comment there)
406+
val validity = initial.validFor
407+
val shiftedContext = ctx.withPhase(validity.phaseId)
408+
Symbols.toDenot(symbol)(shiftedContext).maybeOwner
409+
} else NoSymbol
410+
402411
/** The encoded full path name of this denotation, where outer names and inner names
403412
* are separated by `separator` strings as indicated by the given name kind.
404413
* Drops package objects. Represents each term in the owner chain by a simple `_$`.

0 commit comments

Comments
 (0)