Skip to content

Commit 1debee6

Browse files
committed
Treat Unit type specially in overloading resolution
If the expected type is Unit, any parameterless member should be considered applicable when doing overloading resolution.
1 parent 9aae65c commit 1debee6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ object ProtoTypes {
4040
/** Test compatibility after normalization in a fresh typerstate. */
4141
def normalizedCompatible(tp: Type, pt: Type)(implicit ctx: Context) = {
4242
val nestedCtx = ctx.fresh.setExploreTyperState
43-
isCompatible(normalize(tp, pt)(nestedCtx), pt)(nestedCtx)
43+
val normTp = normalize(tp, pt)(nestedCtx)
44+
isCompatible(normTp, pt)(nestedCtx) ||
45+
pt.isRef(defn.UnitClass) && normTp.isParameterless
4446
}
4547

4648
private def disregardProto(pt: Type)(implicit ctx: Context): Boolean = pt.dealias match {

0 commit comments

Comments
 (0)