Skip to content

Commit

Permalink
Add debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Sep 16, 2024
1 parent f0b6763 commit 97f7aa9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5944,6 +5944,16 @@ object Types extends TypeUtils {

def samClass(tp: Type)(using Context): Symbol = tp match
case tp: ClassInfo =>
val cls = tp.cls
def zeroParamsOLD(tp: Type): Boolean = tp.stripPoly match
case mt: MethodType => mt.paramInfos.isEmpty && !mt.resultType.isInstanceOf[MethodType]
case et: ExprType => true
case _ => false
val validCtorOLD =
val ctor = cls.primaryConstructor
// `ContextFunctionN` does not have constructors
!ctor.exists || zeroParamsOLD(ctor.info)

def zeroParams(tp: Type): Boolean = tp.stripPoly match
case mt: MethodType =>
val noArgsNeeded = mt.paramInfos match
Expand All @@ -5957,9 +5967,14 @@ object Types extends TypeUtils {
val ctor = cls.primaryConstructor
(!ctor.exists || zeroParams(ctor.info)) // `ContextFunctionN` does not have constructors
&& (!cls.is(Trait) || validCtor(cls.info.parents.head.classSymbol))
val validCtorNEW = validCtor(tp.cls)

if validCtorNEW != validCtorOLD then
println(i"SAM change for $tp with parent ${cls.info.parents.head.classSymbol.fullName}, now $validCtorNEW")

def isInstantiable =
!tp.cls.isOneOf(FinalOrSealed) && (tp.appliedRef <:< tp.selfType)
if validCtor(tp.cls) && isInstantiable then tp.cls
if validCtorNEW && isInstantiable then tp.cls
else NoSymbol
case tp: AppliedType =>
samClass(tp.superType)
Expand Down

0 comments on commit 97f7aa9

Please sign in to comment.