File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -861,6 +861,10 @@ object TypeOps:
861861 }
862862
863863 def instantiate (): Type = {
864+ // if there's a change in variance in type parameters (between subtype tp1 and supertype tp2)
865+ // then we don't want to maximise the type variables in the wrong direction.
866+ // For instance 15967, A[-Z] and B[Y] extends A[Y], we don't want to maximise Y to Any
867+ maximizeType(protoTp1.baseType(tp2.classSymbol), NoSpan )
864868 maximizeType(protoTp1, NoSpan )
865869 wildApprox(protoTp1)
866870 }
Original file line number Diff line number Diff line change 1+ // scalac: -Werror
2+ sealed trait A [- Z ]
3+ final case class B [Y ]() extends A [Y ]
4+
5+ class Test :
6+ def t1 [X ](a : A [X ]) = a match // was inexhaustive
7+ case _ : B [X ] @ unchecked =>
8+
9+ // def t2[X](a: A[X]) = a match // was inexhaustive
10+ // case _: B[X] => // expected unchecked warning
You can’t perform that action at this time.
0 commit comments