From 160f63f3ceba49d4a0b9a24efbd162acc79fc9a7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 2 May 2015 21:44:59 +0200 Subject: Fix #523: Instantiate lower bound when bounds checking Lower bounds need to be instantiated just like upper bounds. F-bounded polymorphism (which only applies too upper bounds) is one reason for instantiating arguments, but parameters referring to other parameters is another one. An the latter applies to lower bounds as well. --- src/dotty/tools/dotc/core/TypeOps.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/core/TypeOps.scala') diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 2b6ea49e8..1adabbd2d 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -352,10 +352,11 @@ trait TypeOps { this: Context => // TODO: Make standalone object. //println(i"instantiating ${bounds.hi} with $argTypes") //println(i" = ${instantiate(bounds.hi, argTypes)}") val hiBound = instantiate(bounds.hi, argTypes.mapConserve(_.bounds.hi)) + val loBound = instantiate(bounds.lo, argTypes.mapConserve(_.bounds.lo)) // Note that argTypes can contain a TypeBounds type for arguments that are // not fully determined. In that case we need to check against the hi bound of the argument. if (!(lo <:< hiBound)) violations += ((arg, "upper", hiBound)) - if (!(bounds.lo <:< hi)) violations += ((arg, "lower", bounds.lo)) + if (!(loBound <:< hi)) violations += ((arg, "lower", bounds.lo)) } arg.tpe match { case TypeBounds(lo, hi) => checkOverlapsBounds(lo, hi) -- cgit v1.2.3