Skip to content

Commit 97f7aa9

Browse files
committed
Add debug code
1 parent f0b6763 commit 97f7aa9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5944,6 +5944,16 @@ object Types extends TypeUtils {
59445944

59455945
def samClass(tp: Type)(using Context): Symbol = tp match
59465946
case tp: ClassInfo =>
5947+
val cls = tp.cls
5948+
def zeroParamsOLD(tp: Type): Boolean = tp.stripPoly match
5949+
case mt: MethodType => mt.paramInfos.isEmpty && !mt.resultType.isInstanceOf[MethodType]
5950+
case et: ExprType => true
5951+
case _ => false
5952+
val validCtorOLD =
5953+
val ctor = cls.primaryConstructor
5954+
// `ContextFunctionN` does not have constructors
5955+
!ctor.exists || zeroParamsOLD(ctor.info)
5956+
59475957
def zeroParams(tp: Type): Boolean = tp.stripPoly match
59485958
case mt: MethodType =>
59495959
val noArgsNeeded = mt.paramInfos match
@@ -5957,9 +5967,14 @@ object Types extends TypeUtils {
59575967
val ctor = cls.primaryConstructor
59585968
(!ctor.exists || zeroParams(ctor.info)) // `ContextFunctionN` does not have constructors
59595969
&& (!cls.is(Trait) || validCtor(cls.info.parents.head.classSymbol))
5970+
val validCtorNEW = validCtor(tp.cls)
5971+
5972+
if validCtorNEW != validCtorOLD then
5973+
println(i"SAM change for $tp with parent ${cls.info.parents.head.classSymbol.fullName}, now $validCtorNEW")
5974+
59605975
def isInstantiable =
59615976
!tp.cls.isOneOf(FinalOrSealed) && (tp.appliedRef <:< tp.selfType)
5962-
if validCtor(tp.cls) && isInstantiable then tp.cls
5977+
if validCtorNEW && isInstantiable then tp.cls
59635978
else NoSymbol
59645979
case tp: AppliedType =>
59655980
samClass(tp.superType)

0 commit comments

Comments
 (0)