File tree 1 file changed +7
-10
lines changed
compiler/src/dotty/tools/dotc/transform/localopt
1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -66,16 +66,13 @@ class InlineLocalObjects(val simplifyPhase: Simplify) extends Optimisation {
66
66
object NewCaseClassValDef {
67
67
def unapply (t : ValDef )(implicit ctx : Context ): Option [(Tree , List [Tree ])] =
68
68
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))
79
76
case _ => None
80
77
}
81
78
}
You can’t perform that action at this time.
0 commit comments