aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-12-19 10:15:06 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-12-20 18:33:44 +0100
commitc4da13f5dc4812e36c5b9727b5aceed44a9ce35b (patch)
tree7f82ec0bf680174d764c007c12375d957c3c90bb /compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
parentd9f66a2d3a781bb2538a3e4569f8af245f3374d4 (diff)
downloaddotty-c4da13f5dc4812e36c5b9727b5aceed44a9ce35b.tar.gz
dotty-c4da13f5dc4812e36c5b9727b5aceed44a9ce35b.tar.bz2
dotty-c4da13f5dc4812e36c5b9727b5aceed44a9ce35b.zip
Treat Unit type specially in overloading resolution
If the expected type is Unit, any parameterless member should be considered applicable when doing overloading resolution.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
index 3c318a6af..eb46a131f 100644
--- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
+++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
@@ -40,7 +40,9 @@ object ProtoTypes {
/** Test compatibility after normalization in a fresh typerstate. */
def normalizedCompatible(tp: Type, pt: Type)(implicit ctx: Context) = {
val nestedCtx = ctx.fresh.setExploreTyperState
- isCompatible(normalize(tp, pt)(nestedCtx), pt)(nestedCtx)
+ val normTp = normalize(tp, pt)(nestedCtx)
+ isCompatible(normTp, pt)(nestedCtx) ||
+ pt.isRef(defn.UnitClass) && normTp.isParameterless
}
private def disregardProto(pt: Type)(implicit ctx: Context): Boolean = pt.dealias match {