Skip to content

Commit 015bbbb

Browse files
authored
Merge pull request #9909 from dotty-staging/fix-8988
2 parents 6f632b4 + f07c477 commit 015bbbb

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ object TypeOps:
152152
simplify(l, theMap) & simplify(r, theMap)
153153
case OrType(l, r) if !ctx.mode.is(Mode.Type) =>
154154
simplify(l, theMap) | simplify(r, theMap)
155+
case AnnotatedType(parent, annot)
156+
if !ctx.mode.is(Mode.Type) && annot.symbol == defn.UncheckedVarianceAnnot =>
157+
simplify(parent, theMap)
155158
case _: MatchType =>
156159
val normed = tp.tryNormalize
157160
if (normed.exists) normed else mapOver

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class PlainPrinter(_ctx: Context) extends Printer {
5656
homogenize(tp1) & homogenize(tp2)
5757
case OrType(tp1, tp2) =>
5858
homogenize(tp1) | homogenize(tp2)
59+
case AnnotatedType(parent, annot)
60+
if !ctx.mode.is(Mode.Type) && annot.symbol == defn.UncheckedVarianceAnnot =>
61+
homogenize(parent)
5962
case tp: SkolemType =>
6063
homogenize(tp.info)
6164
case tp: LazyRef =>

compiler/test/dotc/pos-from-tasty.blacklist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ i7087.scala
1313
# Nullability
1414
nullable.scala
1515
notNull.scala
16+
17+
# cyclic reference involving @uncheckedVariance
18+
annot-bootstrap.scala

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ i7757.scala
4646

4747
# splice type tag dealiased in this reference
4848
i8651b.scala
49+
50+
# uneliminated @uncheckedVariance after pickling
51+
annot-bootstrap.scala

tests/neg/i8988.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i8988.scala:3:17 --------------------------------------------------------------
2+
3 |val zs: String = ys // error: (but type should not mention @uncheckedVariance)
3+
| ^^
4+
| Found: (ys : List[Int])
5+
| Required: String

tests/neg/i8988.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
val xs = List(1, 2, 3)
2+
val ys = xs.tail
3+
val zs: String = ys // error: (but type should not mention @uncheckedVariance)

0 commit comments

Comments
 (0)