Skip to content

Commit 50dbfdc

Browse files
committed
Fix caching of baseData in SymDenotations
Without the setting, the outdated baseData cache will be used which produces incorrect baseClasses
1 parent cc55381 commit 50dbfdc

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
7575

7676
override def changesMembers: Boolean = true // the phase adds super accessors and synthetic members
7777

78+
/**
79+
* Serializable and AbstractFunction are added for scala2-library companion object of case class
80+
*
81+
* Ideally `compilingScala2StdLib` should be used, but it is initialized too late to be effective.
82+
*/
83+
override def changesParents: Boolean = true
84+
7885
override def transformPhase(using Context): Phase = thisPhase.next
7986

8087
def newTransformer(using Context): Transformer =

compiler/src/dotty/tools/dotc/transform/init/Checker.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ class Checker extends Phase:
3636
traverser.traverse(unit.tpdTree)
3737

3838
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] =
39-
val checkCtx = ctx.fresh.setPhase(this.start)
39+
val checkCtx = ctx.fresh.setPhase(this)
4040
val traverser = new InitTreeTraverser()
41-
val unitContexts = units.map(unit => checkCtx.fresh.setCompilationUnit(unit))
4241

4342
val units0 =
44-
for unitContext <- unitContexts if traverse(traverser)(using unitContext) yield unitContext.compilationUnit
43+
for
44+
unit <- units
45+
unitContext = checkCtx.fresh.setCompilationUnit(unit)
46+
if traverse(traverser)(using unitContext)
47+
yield
48+
unitContext.compilationUnit
4549

4650
cancellable {
4751
val classes = traverser.getClasses()

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import StdNames.*
1111
import Names.TermName
1212
import NameKinds.OuterSelectName
1313
import NameKinds.SuperAccessorName
14+
import Decorators.*
1415

1516
import ast.tpd.*
1617
import util.{ SourcePosition, NoSourcePosition }
@@ -66,12 +67,11 @@ import dotty.tools.dotc.core.Flags.AbstractOrTrait
6667
* whole-program analysis. However, the check is not modular in terms of project boundaries.
6768
*
6869
*/
69-
import Decorators.*
7070
class Objects(using Context @constructorOnly):
7171
val immutableHashSetBuider: Symbol = requiredClass("scala.collection.immutable.HashSetBuilder")
7272
// TODO: this should really be an annotation on the rhs of the field initializer rather than the field itself.
7373
val HashSetBuilder_rootNode: Symbol = immutableHashSetBuider.requiredValue("rootNode")
74-
74+
7575
val whiteList = Set(HashSetBuilder_rootNode)
7676

7777
// ----------------------------- abstract domain -----------------------------

0 commit comments

Comments
 (0)