File tree 2 files changed +14
-0
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -875,6 +875,10 @@ object TypeOps:
875
875
}
876
876
877
877
def instantiate (): Type = {
878
+ // if there's a change in variance in type parameters (between subtype tp1 and supertype tp2)
879
+ // then we don't want to maximise the type variables in the wrong direction.
880
+ // For instance 15967, A[-Z] and B[Y] extends A[Y], we don't want to maximise Y to Any
881
+ maximizeType(protoTp1.baseType(tp2.classSymbol), NoSpan )
878
882
maximizeType(protoTp1, NoSpan )
879
883
wildApprox(protoTp1)
880
884
}
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