File tree Expand file tree Collapse file tree 3 files changed +28
-10
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -189,16 +189,14 @@ trait PatternTypeConstrainer { self: TypeComparer =>
189
189
case _ => false
190
190
}
191
191
192
- def widenVariantParams = new TypeMap {
193
- def apply (tp : Type ) = mapOver(tp) match {
194
- case tp @ AppliedType (tycon, args) =>
195
- val args1 = args.zipWithConserve(tycon.typeParams)((arg, tparam) =>
196
- if (tparam.paramVarianceSign != 0 ) TypeBounds .empty else arg
197
- )
198
- tp.derivedAppliedType(tycon, args1)
199
- case tp =>
200
- tp
201
- }
192
+ def widenVariantParams (tp : Type ) = tp match {
193
+ case tp @ AppliedType (tycon, args) =>
194
+ val args1 = args.zipWithConserve(tycon.typeParams)((arg, tparam) =>
195
+ if (tparam.paramVarianceSign != 0 ) TypeBounds .empty else arg
196
+ )
197
+ tp.derivedAppliedType(tycon, args1)
198
+ case tp =>
199
+ tp
202
200
}
203
201
204
202
val widePt =
Original file line number Diff line number Diff line change
1
+ @ main def test : Unit = {
2
+ trait TyCon [+ A ]
3
+ trait S [T ]
4
+ trait P [T ] extends S [TyCon [T ]] {
5
+ def consume (t : T ): Unit
6
+ }
7
+
8
+ def patmat (s : S [TyCon [Int ]]) = s match {
9
+ case p : P [t] =>
10
+ p.consume(" Hi" ) // error
11
+ }
12
+
13
+ patmat(new P [Int ] {
14
+ override def consume (t : Int ): Unit = t + 1
15
+ })
16
+ }
Original file line number Diff line number Diff line change 1
1
object `invariant-gadt` {
2
2
case class Invariant [T ](value : T )
3
3
4
+ def soundInPrinciple [T ](i : Invariant [T ]) : Int = i match {
5
+ case _ : Invariant [Int ] => i.value
6
+ }
7
+
4
8
def unsound0 [T ](t : T ): T = Invariant (t) match {
5
9
case Invariant (_ : Int ) =>
6
10
(0 : Any ) // error
You can’t perform that action at this time.
0 commit comments