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 =>
189189 case _ => false
190190 }
191191
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
202200 }
203201
204202 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 11object `invariant-gadt` {
22 case class Invariant [T ](value : T )
33
4+ def soundInPrinciple [T ](i : Invariant [T ]) : Int = i match {
5+ case _ : Invariant [Int ] => i.value
6+ }
7+
48 def unsound0 [T ](t : T ): T = Invariant (t) match {
59 case Invariant (_ : Int ) =>
610 (0 : Any ) // error
You can’t perform that action at this time.
0 commit comments