From 036a9bbd0be2b71fc9d60954fd0b1b64c9a181af Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Fri, 26 Sep 2014 09:24:50 +1000 Subject: SI-8079 Only expand local aliases during variance checks We've been flip-flopping on this one through the years, right now we issue an two errors for the enclosed test. After this commit, variance validation only expands aliases that are `{private,protected}[this]`. The rest need not be expanded, as we have already variance validated the RHS of the alias. It also removes a seemingly incorrect check in `isLocalOnly`. This also means that we can use `@uncheckedVariance` to create variant type aliases for Java interfaces. However, if such a type alias is declared private local, it *will* be expanded. That shouldn't be a problem, other than for the fact that we run through an as-seen-from that strips the `@uV` annotations in the type expansion. This has been recorded in a pending test. --- test/pending/pos/t8079c.scala | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/pending/pos/t8079c.scala (limited to 'test/pending') diff --git a/test/pending/pos/t8079c.scala b/test/pending/pos/t8079c.scala new file mode 100644 index 0000000000..ae7f37e2bf --- /dev/null +++ b/test/pending/pos/t8079c.scala @@ -0,0 +1,7 @@ +trait F1[/* - */T, /* + */ R] + +object Test { + import scala.annotation.unchecked._ + private[this] type VariantF1[-T, +R] = F1[T @uncheckedVariance, R @uncheckedVariance] + trait C[+T] { def foo: VariantF1[Any, T] } +} -- cgit v1.2.3