File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import scala.collection.immutable.ListSet
2727import scala .collection .mutable
2828import scala .annotation .tailrec
2929import 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 }
You can’t perform that action at this time.
0 commit comments