File tree 1 file changed +3
-3
lines changed
compiler/src/dotty/tools/dotc/transform/init 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
27
27
import scala .collection .mutable
28
28
import scala .annotation .tailrec
29
29
import scala .annotation .constructorOnly
30
+ import dotty .tools .dotc .core .Flags .AbstractOrTrait
30
31
31
32
/** Check initialization safety of static objects
32
33
*
@@ -618,8 +619,7 @@ object Objects:
618
619
case ValueSet (values) => values.map(v => v.filterClass(klass)).join
619
620
case arr : OfArray => if defn.ArrayClass .isSubClass(klass) then arr else Bottom
620
621
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
623
623
624
624
extension (value : Ref | Cold .type )
625
625
def widenRefOrCold (height : Int )(using Context ) : Ref | Cold .type = value.widen(height).asInstanceOf [ThisValue ]
@@ -1572,7 +1572,7 @@ object Objects:
1572
1572
report.warning(" The argument should be a constant integer value" , arg)
1573
1573
res.widen(1 )
1574
1574
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
1576
1576
1577
1577
argInfos += ArgInfo (widened, trace.add(arg.tree), arg.tree)
1578
1578
}
You can’t perform that action at this time.
0 commit comments