From c61892842cebdee0dbb0c7a80bb468ae20ea57e1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 22 Jun 2015 11:08:22 +0200 Subject: Avoid junk produced by Constraint#replace. There were two instances where a constraint undergoing a replace would still refer to poly params that are no longer bound after the replace. 1. In an ordering the replaced parameters was n ot removed from the bounds of the others. 2. When a parameter refers to the replaced parameter in a type, (not a TypeBounds), the replaced parameter was not replaced. We now have checking in place that in globally committable typer states, TypeVars are not instantiated to PolyParams and (configurable) that constraints of such typer states are always closed. Fixes #670. --- tests/pos/t8230a.scala | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/pos/t8230a.scala (limited to 'tests/pos/t8230a.scala') diff --git a/tests/pos/t8230a.scala b/tests/pos/t8230a.scala new file mode 100644 index 000000000..f878eacf8 --- /dev/null +++ b/tests/pos/t8230a.scala @@ -0,0 +1,26 @@ +trait Arr[T] +object Arr { + def apply[T](xs: T): Arr[T] = null + def apply(x: Long) : Arr[Long] = null +} + +object I { + implicit def arrToTrav[T] (a: Arr[T]) : Traversable[T] = null + implicit def longArrToTrav(a: Arr[Long]): Traversable[Long] = null +} + +object Test { + def foo(t: Traversable[Any]) = {} + + object Okay { + Arr("1") + + import I.{ arrToTrav, longArrToTrav } + val x = foo(Arr("2")) + } + + object Fail { +// import I.arrToTrav +// foo(Arr("3")) // found String, expected Long + } +} -- cgit v1.2.3