Skip to content

Commit b9b9388

Browse files
committed
Drop mayBeTypePat
It does not seem to serve a purpose. The only test where it was used does not really make sense.
1 parent f47e895 commit b9b9388

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ object desugar {
14401440
def collect(tree: Tree): Unit = tree match {
14411441
case Bind(nme.WILDCARD, tree1) =>
14421442
collect(tree1)
1443-
case tree @ Bind(_, Typed(tree1, tpt)) if !mayBeTypePat(tpt) =>
1443+
case tree @ Bind(_, Typed(tree1, tpt)) =>
14441444
add(tree, tpt)
14451445
collect(tree1)
14461446
case tree @ Bind(_, tree1) =>

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
164164
/** Is name a left-associative operator? */
165165
def isLeftAssoc(operator: Name): Boolean = !operator.isEmpty && (operator.toSimpleName.last != ':')
166166

167-
/** can this type be a type pattern? */
168-
def mayBeTypePat(tree: Tree): Boolean = unsplice(tree) match {
169-
case RefinedTypeTree(tpt, refinements) => mayBeTypePat(tpt) || refinements.exists(_.isInstanceOf[Bind])
170-
case AppliedTypeTree(tpt, args) => mayBeTypePat(tpt) || args.exists(_.isInstanceOf[Bind])
171-
case Select(tpt, _) => mayBeTypePat(tpt)
172-
case Annotated(tpt, _) => mayBeTypePat(tpt)
173-
case _ => false
174-
}
175-
176167
/** Is this argument node of the form <expr> : _*, or is it a reference to
177168
* such an argument ? The latter case can happen when an argument is lifted.
178169
*/

tests/neg/patvars.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
object Test {
2+
3+
(??? : Any) match {
4+
5+
case x1 | y1 => ??? // error // error
6+
7+
case _: List[t2] | y2 => ??? // error // error
8+
9+
case x3: Int | y3: String => ??? // error // error
10+
11+
}
12+
}

0 commit comments

Comments
 (0)