@@ -5963,25 +5963,21 @@ object Types extends TypeUtils {
5963
5963
noArgsNeeded && ! mt.resultType.isInstanceOf [MethodType ]
5964
5964
case et : ExprType => true
5965
5965
case _ => false
5966
- def validCtor (cls : Symbol ): Boolean =
5967
- val ctor = cls.primaryConstructor
5968
- if ! ctor.exists then true // `ContextFunctionN` does not have constructors
5969
- else if ! zeroParams(ctor.info) then false
5970
- else if ! cls.is(Trait ) then true
5971
- else
5972
- val firstParentCls = cls.info.parents.head.classSymbol
5973
- if firstParentCls.isClass && ! firstParentCls.is(Trait ) then
5974
- validCtor(firstParentCls) // need to check class constructor as well
5975
- else
5976
- true
5977
- val validCtorNEW = validCtor(tp.cls)
5978
-
5979
- if validCtorNEW != validCtorOLD then
5980
- println(i " SAM change for $tp with parent ${cls.info.parents.head.classSymbol.fullName}, now $validCtorNEW" )
5966
+ def takesNoArgs (tp : Type ) =
5967
+ val constrs = tp.decl(nme.CONSTRUCTOR )
5968
+ ! constrs.exists // `ContextFunctionN` does not have constructors
5969
+ || constrs.hasAltWith(constr => zeroParams(constr.info))
5970
+ def firstParentCls = cls.info.parents.head.classSymbol
5971
+ val noArgsNeeded : Boolean =
5972
+ takesNoArgs(tp)
5973
+ && (! tp.cls.is(Trait ) || takesNoArgs(tp.cls.info.parents.head))
5974
+
5975
+ if noArgsNeeded != validCtorOLD then
5976
+ println(i " SAM change for $tp with parent ${firstParentCls.fullName}, now $noArgsNeeded" )
5981
5977
5982
5978
def isInstantiable =
5983
5979
! tp.cls.isOneOf(FinalOrSealed ) && (tp.appliedRef <:< tp.selfType)
5984
- if validCtorNEW && isInstantiable then tp.cls
5980
+ if noArgsNeeded && isInstantiable then tp.cls
5985
5981
else NoSymbol
5986
5982
case tp : AppliedType =>
5987
5983
samClass(tp.superType)
0 commit comments