From b31f9ab97912ad2d26df16ef223b874970175388 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 17 Feb 2014 22:13:19 +0100 Subject: SI-8301 fix regression with refinement subtyping, wildcard type. In the enclosed test case, the list of candidate implicit is checked for eligibility with the view by: pt = Test.sym.type => ?{def asFreeType: ?} tp = (sym: Test.u.Symbol)Test.u.CompatibleSymbol matchesPt(tp, pt) This ends up in `TypeComparers#specializesSym`, which compares: symLo = asFreeType: => Universe.this.TypeSymbol symHi = asFreeType: ? Before the regression in fada1ef6, that method called `isStable` on both of these to make sure that `symLo` was as least as stable as `symHi`. Both returned `false`, and, they matched. After that refactoring, two calls were made. `isStable` *only* checked for stability, and gave the same results as before. But, the new check for volatility believes that the low symbol was more volatile than the high, because `WildCardType` is treated as non-volatile. Really, it should have the same volatility as whatever it is being compared to, so that these sort of comparisons yield true. This commit ammends `specializesSym` to special case `symHi: ?`, and ignore the volatilty gap in that case. --- test/files/pos/t8301.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/files/pos/t8301.scala (limited to 'test/files') diff --git a/test/files/pos/t8301.scala b/test/files/pos/t8301.scala new file mode 100644 index 0000000000..2d10864c57 --- /dev/null +++ b/test/files/pos/t8301.scala @@ -0,0 +1,19 @@ +trait Universe { + type Symbol >: Null <: AnyRef with SymbolApi + trait SymbolApi + + type TypeSymbol >: Null <: TypeSymbolApi with Symbol + trait TypeSymbolApi + + implicit class CompatibleSymbol(sym: Symbol) { + def asFreeType: TypeSymbol = ??? + } +} + +object Test extends App { + val u: Universe = ??? + import u._ + + val sym: Symbol = ??? + sym.asFreeType +} -- cgit v1.2.3