Skip to content

Commit f8a81b1

Browse files
committed
address review comments
- add check files for run/unroll tests - refactorings - test clause interleaving and value class
1 parent c1c1e95 commit f8a81b1

File tree

48 files changed

+427
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+427
-142
lines changed

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class CompilationUnit protected (val source: SourceFile, val info: CompilationUn
5959

6060
var hasMacroAnnotations: Boolean = false
6161

62-
def hasUnrollDefs: Boolean = unrolledClasses != null
63-
var unrolledClasses: Set[Symbol] | Null = null
62+
def hasUnrollDefs: Boolean = unrolledClasses.nonEmpty
63+
var unrolledClasses: Set[Symbol] = Set.empty
6464

6565
/** Set to `true` if inliner added anonymous mirrors that need to be completed */
6666
var needsMirrorSupport: Boolean = false

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,9 @@ object Denotations {
10721072
def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation =
10731073
if (denots.exists && denots.matches(this)) NoDenotation else this
10741074
def filterWithFlags(required: FlagSet, excluded: FlagSet)(using Context): SingleDenotation =
1075-
val realExcluded = if ctx.isAfterTyper then excluded else excluded | (if ctx.mode.is(Mode.ResolveFromTASTy) then EmptyFlags else Invisible)
1075+
val realExcluded =
1076+
if ctx.isAfterTyper || ctx.mode.is(Mode.ResolveFromTASTy) then excluded
1077+
else excluded | Invisible
10761078
def symd: SymDenotation = this match
10771079
case symd: SymDenotation => symd
10781080
case _ => symbol.denot

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import collection.mutable
2020
import reporting.{Profile, NoProfile}
2121
import dotty.tools.tasty.TastyFormat.ASTsSection
2222
import quoted.QuotePatterns
23-
import dotty.tools.dotc.config.Feature
2423

2524
object TreePickler:
2625
class StackSizeExceeded(val mdef: tpd.MemberDef) extends Exception
@@ -475,16 +474,15 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
475474
case _ =>
476475
if passesConditionForErroringBestEffortCode(tree.hasType) then
477476
// #19951 The signature of a constructor of a Java annotation is irrelevant
478-
val sym = tree.symbol
479477
val sig =
480-
if name == nme.CONSTRUCTOR && sym.exists && sym.owner.is(JavaAnnotation) then Signature.NotAMethod
478+
if name == nme.CONSTRUCTOR && tree.symbol.exists && tree.symbol.owner.is(JavaAnnotation) then Signature.NotAMethod
481479
else tree.tpe.signature
482-
var ename = sym.targetName
480+
var ename = tree.symbol.targetName
483481
val selectFromQualifier =
484482
name.isTypeName
485483
|| qual.isInstanceOf[Hole] // holes have no symbol
486484
|| sig == Signature.NotAMethod // no overload resolution necessary
487-
|| !sym.exists // polymorphic function type
485+
|| !tree.denot.symbol.exists // polymorphic function type
488486
|| tree.denot.asSingleDenotation.isRefinedMethod // refined methods have no defining class symbol
489487
if selectFromQualifier then
490488
writeByte(if name.isTypeName then SELECTtpt else SELECT)
@@ -493,9 +491,9 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
493491
else // select from owner
494492
writeByte(SELECTin)
495493
withLength {
496-
pickleNameAndSig(name, sym.signature, ename)
494+
pickleNameAndSig(name, tree.symbol.signature, ename)
497495
pickleTree(qual)
498-
pickleType(sym.owner.typeRef)
496+
pickleType(tree.symbol.owner.typeRef)
499497
}
500498
else
501499
writeByte(if name.isTypeName then SELECTtpt else SELECT)

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3416,7 +3416,7 @@ extends DeclarationMsg(IllegalUnrollPlacementID):
34163416
case Some(method) =>
34173417
val isCtor = method.isConstructor
34183418
def what = if isCtor then i"a ${if method.owner.is(Trait) then "trait" else "class"} constructor" else i"method ${method.name}"
3419-
val prefix = s"Can not unroll parameters of $what"
3419+
val prefix = s"Cannot unroll parameters of $what"
34203420
if method.is(Deferred) then
34213421
i"$prefix: it must not be abstract"
34223422
else if isCtor && method.owner.is(Trait) then

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,12 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
120120

121121
private var inJavaAnnot: Boolean = false
122122

123-
private var seenUnrolledMethods: util.EqHashMap[Symbol, Boolean] | Null = null
123+
private val seenUnrolledMethods: util.EqHashMap[Symbol, Boolean] = new util.EqHashMap[Symbol, Boolean]
124124

125125
private var noCheckNews: Set[New] = Set()
126126

127127
def isValidUnrolledMethod(method: Symbol, origin: SrcPos)(using Context): Boolean =
128-
val seenMethods =
129-
val local = seenUnrolledMethods
130-
if local == null then
131-
val map = new util.EqHashMap[Symbol, Boolean]
132-
seenUnrolledMethods = map
133-
map
134-
else
135-
local
136-
seenMethods.getOrElseUpdate(method, {
128+
seenUnrolledMethods.getOrElseUpdate(method, {
137129
val isCtor = method.isConstructor
138130
if
139131
method.name.is(DefaultGetterName)
@@ -234,12 +226,8 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
234226
private def registerIfUnrolledParam(sym: Symbol)(using Context): Unit =
235227
if sym.hasAnnotation(defn.UnrollAnnot) && isValidUnrolledMethod(sym.owner, sym.sourcePos) then
236228
val cls = sym.enclosingClass
237-
val classes = ctx.compilationUnit.unrolledClasses
238229
val additions = Array(cls, cls.linkedClass).filter(_ != NoSymbol)
239-
if classes == null then
240-
ctx.compilationUnit.unrolledClasses = Set.from(additions)
241-
else
242-
ctx.compilationUnit.unrolledClasses = classes ++ additions
230+
ctx.compilationUnit.unrolledClasses ++= additions
243231

244232
private def processValOrDefDef(tree: Tree)(using Context): tree.type =
245233
val sym = tree.symbol

0 commit comments

Comments
 (0)