Skip to content

Commit 23c74b3

Browse files
Workaround cyclic reference error...
1 parent 4a8b7b4 commit 23c74b3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

compiler/src/dotty/tools/dotc/transform/localopt/InlineLocalObjects.scala

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,13 @@ class InlineLocalObjects(val simplifyPhase: Simplify) extends Optimisation {
6666
object NewCaseClassValDef {
6767
def unapply(t: ValDef)(implicit ctx: Context): Option[(Tree, List[Tree])] =
6868
t.rhs match {
69-
case Apply(fun, args) =>
70-
val isCaseClass = t.symbol.info.classSymbol is CaseClass
71-
val isVal = !t.symbol.is(Lazy | Mutable)
72-
val notMutableCC = !t.symbol.info.classSymbol.caseAccessors.exists(_.is(Mutable))
73-
val isConstructor = fun.symbol.isConstructor
74-
// Rules out case class inheritance and enums
75-
val notWeirdCC = t.tpe.widenDealias == t.symbol.info.widenDealias.finalResultType.widenDealias
76-
if (isCaseClass && isVal && notMutableCC && isConstructor && notWeirdCC)
77-
Some((fun, args))
78-
else None
69+
case Apply(fun, args)
70+
if t.symbol.info.classSymbol.is(CaseClass) && // is rhs a case class?
71+
!t.symbol.is(Lazy | Mutable) && // is lhs a val?
72+
!t.symbol.info.classSymbol.caseAccessors.exists(_.is(Mutable)) && // is the case class immutable?
73+
fun.symbol.isConstructor && // is rhs a new?
74+
t.tpe.widenDealias == t.symbol.info.finalResultType.widenDealias => // no case class inheritance or enums
75+
Some((fun, args))
7976
case _ => None
8077
}
8178
}

0 commit comments

Comments
 (0)