Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
else (tree.rhs, sym.info) match
case (rhs: LambdaTypeTree, bounds: TypeBounds) =>
VarianceChecker.checkLambda(rhs, bounds)
if sym.isOpaqueAlias then
VarianceChecker.checkLambda(rhs, TypeBounds.upper(sym.opaqueAlias))
case _ =>
processMemberDef(super.transform(tree))
case tree: New if isCheckable(tree) =>
Expand Down
10 changes: 10 additions & 0 deletions tests/neg/i13997.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
opaque type CovariantArray[+A] = Array[A] // error

object CovariantArray:
def crash() =
val stringArray: CovariantArray[String] = Array("foo", "bar")
val anyArray: CovariantArray[Any] = stringArray
anyArray(0) = 42
stringArray(0).length

@main def Test = CovariantArray.crash()