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 @@ -863,6 +863,10 @@ object TypeOps:
863863 }
864864
865865 def instantiate (): Type = {
866+ // if there's a change in variance in type parameters (between subtype tp1 and supertype tp2)
867+ // then we don't want to maximise the type variables in the wrong direction.
868+ // For instance 15967, A[-Z] and B[Y] extends A[Y], we don't want to maximise Y to Any
869+ maximizeType(protoTp1.baseType(tp2.classSymbol), NoSpan )
866870 maximizeType(protoTp1, NoSpan )
867871 wildApprox(protoTp1)
868872 }
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