From e4775b87c2b5e8f55bb32da9160cd37322a18f2c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 26 Feb 2017 16:12:19 +0100 Subject: Constrain results of dependent implicits No reason why we should not - normalize handles implicit methods just fine. This fixes type errors in test HLists.scala. --- .../src/dotty/tools/dotc/typer/ProtoTypes.scala | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/typer') diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index d666b563e..48f79d147 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -62,14 +62,9 @@ object ProtoTypes { true } case _: ValueTypeOrProto if !disregardProto(pt) => - mt match { - case mt: MethodType => - mt.isDependent || isCompatible(normalize(mt, pt), pt) - case _ => - isCompatible(mt, pt) - } - case _: WildcardType => - isCompatible(mt, pt) + isCompatible(normalize(mt, pt), pt) + case pt: WildcardType if pt.optBounds.exists => + isCompatible(normalize(mt, pt), pt) case _ => true } @@ -421,12 +416,12 @@ object ProtoTypes { if (mt.isDependent) tp else { val rt = normalize(mt.resultType, pt) - pt match { - case pt: IgnoredProto => mt - case pt: ApplyingProto => mt.derivedMethodType(mt.paramNames, mt.paramTypes, rt) - case _ => - val ft = defn.FunctionOf(mt.paramTypes, rt) - if (mt.paramTypes.nonEmpty || ft <:< pt) ft else rt + pt match { + case pt: IgnoredProto => mt + case pt: ApplyingProto => mt.derivedMethodType(mt.paramNames, mt.paramTypes, rt) + case _ => + val ft = defn.FunctionOf(mt.paramTypes, rt) + if (mt.paramTypes.nonEmpty || ft <:< pt) ft else rt } } case et: ExprType => et.resultType -- cgit v1.2.3