Skip to content

Commit 36392fa

Browse files
author
EnzeXing
committed
Minor fix
1 parent 0a95653 commit 36392fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import scala.collection.immutable.ListSet
2727
import scala.collection.mutable
2828
import scala.annotation.tailrec
2929
import scala.annotation.constructorOnly
30+
import dotty.tools.dotc.core.Flags.AbstractOrTrait
3031

3132
/** Check initialization safety of static objects
3233
*
@@ -618,8 +619,7 @@ object Objects:
618619
case ValueSet(values) => values.map(v => v.filterClass(klass)).join
619620
case arr: OfArray => if defn.ArrayClass.isSubClass(klass) then arr else Bottom
620621
case fun: Fun =>
621-
val functionSuperCls = klass.baseClasses.filter(defn.isFunctionClass)
622-
if functionSuperCls.nonEmpty then fun else Bottom
622+
if klass.isOneOf(AbstractOrTrait) && klass.baseClasses.exists(defn.isFunctionClass) then fun else Bottom
623623

624624
extension (value: Ref | Cold.type)
625625
def widenRefOrCold(height : Int)(using Context) : Ref | Cold.type = value.widen(height).asInstanceOf[ThisValue]
@@ -1572,7 +1572,7 @@ object Objects:
15721572
report.warning("The argument should be a constant integer value", arg)
15731573
res.widen(1)
15741574
case _ =>
1575-
res.widen(1) // TODO: changing to widen(2) causes standard library analysis to loop infinitely
1575+
if res.isInstanceOf[Fun] then res.widen(2) else res.widen(1) // TODO: changing to widen(2) causes standard library analysis to loop infinitely
15761576

15771577
argInfos += ArgInfo(widened, trace.add(arg.tree), arg.tree)
15781578
}

0 commit comments

Comments
 (0)