File tree 1 file changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/core
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -5944,6 +5944,16 @@ object Types extends TypeUtils {
5944
5944
5945
5945
def samClass (tp : Type )(using Context ): Symbol = tp match
5946
5946
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
+
5947
5957
def zeroParams (tp : Type ): Boolean = tp.stripPoly match
5948
5958
case mt : MethodType =>
5949
5959
val noArgsNeeded = mt.paramInfos match
@@ -5957,9 +5967,14 @@ object Types extends TypeUtils {
5957
5967
val ctor = cls.primaryConstructor
5958
5968
(! ctor.exists || zeroParams(ctor.info)) // `ContextFunctionN` does not have constructors
5959
5969
&& (! 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
+
5960
5975
def isInstantiable =
5961
5976
! tp.cls.isOneOf(FinalOrSealed ) && (tp.appliedRef <:< tp.selfType)
5962
- if validCtor(tp.cls) && isInstantiable then tp.cls
5977
+ if validCtorNEW && isInstantiable then tp.cls
5963
5978
else NoSymbol
5964
5979
case tp : AppliedType =>
5965
5980
samClass(tp.superType)
You can’t perform that action at this time.
0 commit comments