From dbdb123ae7180b66e5d29ad4dd89b746641a3457 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 19 Dec 2016 16:35:48 +0100 Subject: Fix subtyping of hk types with wildcard arguments Argument comparison of hk types did not take into account that the compared types could have themselves wildcard arguments. --- compiler/src/dotty/tools/dotc/core/TypeComparer.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/core') diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 334306f19..8930983f3 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -757,8 +757,14 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { if (args1.isEmpty) args2.isEmpty else args2.nonEmpty && { val v = tparams.head.paramVariance - (v > 0 || isSubType(args2.head, args1.head)) && - (v < 0 || isSubType(args1.head, args2.head)) + def isSub(tp1: Type, tp2: Type) = tp2 match { + case tp2: TypeBounds => + tp2.contains(tp1) + case _ => + (v > 0 || isSubType(tp2, tp1)) && + (v < 0 || isSubType(tp1, tp2)) + } + isSub(args1.head, args2.head) } && isSubArgs(args1.tail, args2.tail, tparams) /** Test whether `tp1` has a base type of the form `B[T1, ..., Tn]` where -- cgit v1.2.3