Skip to content

Commit 0ba5ee5

Browse files
committed
Convert tests to use new type pattern syntax
Convert many existing occurrences of `t` as a type pattern variable to `type t`.
1 parent 5060aba commit 0ba5ee5

File tree

17 files changed

+27
-23
lines changed

17 files changed

+27
-23
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,14 +1805,12 @@ object Parsers {
18051805

18061806
/** ClsTypeParamClause::= `[' ClsTypeParam {`,' ClsTypeParam} `]'
18071807
* ClsTypeParam ::= {Annotation} [`+' | `-'] TypeParamCore
1808-
*
18091808
* DefTypeParamClause::= `[' DefTypeParam {`,' DefTypeParam} `]'
18101809
* DefTypeParam ::= {Annotation} TypeParamCore
18111810
* TypeParamCore ::= id [HkTypeParamClause] TypeParamBounds
18121811
*
18131812
* TypTypeParamCaluse::= `[' TypTypeParam {`,' TypTypeParam} `]'
18141813
* TypTypeParam ::= {Annotation} id [HkTypePamClause] TypeBounds
1815-
*
18161814
* HkTypeParamClause ::= `[' HkTypeParam {`,' HkTypeParam} `]'
18171815
* HkTypeParam ::= {Annotation} ['+' | `-'] (id [HkTypePamClause] | _') TypeBounds
18181816
*/

docs/docs/internals/syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ SimplePattern1 ::= Path
242242
| SimplePattern1 ‘.’ id
243243
PatVar ::= varid
244244
| ‘_’
245-
BindingTypePattern::= Type
246245
TypePattern ::= RefinedType
247246
Patterns ::= Pattern {‘,’ Pattern}
248247
ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ Apply(fn, pats)
249248
| ‘(’ [Patterns ‘,’] Pattern2 ‘:’ ‘_’ ‘*’ ‘)’
250249
251250
Augmentation ::= ‘augment’ BindingTypePattern
252251
[[nl] ImplicitParamClause] TemplateClause Augment(name, templ)
252+
BindingTypePattern::= Type
253253
```
254254

255255
### Type and Value Parameters

tests/neg-custom-args/i1754.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ case class One[T](fst: T)
22

33
object Test {
44
def bad[T](e: One[T]) = e match {
5-
case foo: One[a] =>
5+
case foo: One[type A] =>
66
val t: T = e.fst
77
val nok: Nothing = t // error
88
}

tests/neg/gadt-eval.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object Test {
2020
def eval2[T](e: Exp[T]): T = e match {
2121
case e: Lit =>
2222
e.value
23-
case e: Pair[t1, t2] =>
23+
case e: Pair[type t1, type t2] =>
2424
(eval(e.fst), eval(e.fst)) // error:
2525
//-- [E007] Type Mismatch Error: tests/neg/gadt-eval.scala:24:6 ------------------
2626
//24 | (eval(e.fst), eval(e.fst))

tests/pos/escapes2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Test {
22
class C3[T](val elem: T)
33
class D3[T](val elemD: T) extends C3[T](elemD)
4-
def f[T](x: C3[T]) = x match { case d: D3[t] => d.elemD }
4+
def f[T](x: C3[T]) = x match { case d: D3[type X] => d.elemD }
55
}

tests/pos/exhaust_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object ExhaustivityWarnBugReportMinimal {
4444

4545
val v2: (Some[_], Int) = (???, ???)
4646
v2 match {
47-
case (x: Some[t], _) =>
47+
case (x: Some[type t], _) =>
4848
}
4949

5050
val v3: (Option[_], FoundNode[_]) = (???, ???)

tests/pos/existentials-harmful.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object ExistentialsConsideredHarmful {
4747
// Type annotation on bc is required ... possible compiler bug?
4848
// val bc : BoxCarrier[_ <: Animal] = aBox match {
4949
val bc = aBox match {
50-
case tb : TransportBox[a] => new BoxCarrier(tb) {
50+
case tb : TransportBox[type A] => new BoxCarrier(tb) {
5151
def speed: Int = 12
5252
}
5353
}

tests/pos/gadt-eval.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object Test {
1313
def eval2[T](e: Exp[T]): T = e match {
1414
case e: Lit =>
1515
e.value
16-
case e: Pair[t1, t2] =>
16+
case e: Pair[type T1, type T2] =>
1717
(eval(e.fst), eval(e.snd))
1818
}
1919
}

tests/pos/i0290-type-bind.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ object foo{
33
x match {
44
case t: List[tt] => t.head.asInstanceOf[tt]
55
}
6+
x match {
7+
case t: List[type tt] => t.head.asInstanceOf[tt]
8+
}
69
}
710

811
object bar {
@@ -12,8 +15,8 @@ object bar {
1215
val x: AnyRef = new C
1316

1417
x match {
15-
case x: C[u] =>
16-
def x: u = x
18+
case x: C[type U] =>
19+
def x: U = x
1720
val s: Seq[_] = x
1821
}
1922
}

tests/pos/i0306.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ object bar {
55
val x: AnyRef = new C
66

77
val y = x match {
8-
case x: C[u] =>
9-
def xx: u = xx
8+
case x: C[type U] =>
9+
def xx: U = xx
1010
xx
1111
}
1212

tests/pos/i1365.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ class Test[A] {
1010
def g(cmd: Message[A]): Unit = cmd match {
1111
case s: Script[z] => s.iterator.foreach(x => g(x))
1212
}
13+
def h(cmd: Message[A]): Unit = cmd match {
14+
case s: Script[type Z] => s.iterator.foreach(x => g(x))
15+
}
1316
}

tests/pos/i947.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ object Test {
66

77
override def equals(other: Any) = other match {
88
case o: c => x == o.x
9-
case xs: List[c] => false
10-
case ys: List[d18383] => false
9+
case xs: List[type C] => false
10+
case ys: List[type d18383] => false
1111
case _ => false
1212
}
1313

tests/pos/t4070.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package a {
22
// method before classes
33
trait Foo {
4-
def crash(x: Dingus[_]): Unit = x match { case m: Bippy[tv] => () }
4+
def crash(x: Dingus[_]): Unit = x match { case m: Bippy[type tv] => () }
55

66
class Dingus[T]
77
class Bippy[CC[X] <: Seq[X]]() extends Dingus[CC[Int]]
@@ -14,7 +14,7 @@ package b {
1414
class Dingus[T]
1515
class Bippy[CC[X] <: Seq[X]]() extends Dingus[CC[Int]]
1616

17-
def crash(x: Dingus[_]): Unit = x match { case m: Bippy[tv] => () }
17+
def crash(x: Dingus[_]): Unit = x match { case m: Bippy[type tv] => () }
1818
}
1919
}
2020

tests/pos/t6205.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
class A[T]
33
class Test1 {
44
def x(backing: Map[A[_], Any]) =
5-
for( (k: A[kt], v) <- backing)
6-
yield (k: A[kt])
5+
for( (k: A[type KT], v) <- backing)
6+
yield (k: A[KT])
77
}
88

99
// this tests same thing as above, but independent of library classes,
@@ -13,6 +13,6 @@ class Mapped[A] { def map[T](f: Holder[A] => T): Iterable[T] = ??? }
1313
class Test2 {
1414
def works(backing: Mapped[A[_]]): Iterable[A[_]]
1515
= backing.map(x =>
16-
x match {case Holder(k: A[kt]) => (k: A[kt])}
16+
x match {case Holder(k: A[type KT]) => (k: A[KT])}
1717
)
1818
}

tests/pos/t6275.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ final class B[T] extends A[T]
55
object ParsedAxis {
66
type BI = B[Int]
77

8-
def f1(a: A[Int]) = a match { case b: B[Int] => 3 }
8+
def f1(a: A[Int]) = a match { case b: B[type Int] => 3 }
99
def f2(a: A[Int]) = a match { case b: BI => 3 }
1010
def f3(a: A[Int]) = a match { case b: B[t] => 3 }
1111
}

tests/pos/t8023.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class D[K]
33

44
object Test3 {
55
def foo = (null: Any) match {
6-
case a: C[k] => new C[k]() // this one worked before as the info of `A` was complete
6+
case a: C[type K] => new C[K]() // this one worked before as the info of `A` was complete
77
// ()
88
}
99
}

tests/pos/t946.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ object pmbugbounds {
33
class Foo[t <: Bar] {}
44

55
(new Foo[Bar]) match {
6-
case _ : Foo[x] => null
6+
case _ : Foo[type X] => null
77
}
88
}

0 commit comments

Comments
 (0)