File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -540,6 +540,11 @@ object Symbols {
540
540
d != null && d.flagsUNSAFE.is(Private )
541
541
}
542
542
543
+ /** Is the symbol a pattern bound symbol?
544
+ */
545
+ final def isPatternBound (implicit ctx : Context ): Boolean =
546
+ ! isClass && this .is(Case , butNot = Enum | Module )
547
+
543
548
/** The symbol's signature if it is completed or a method, NotAMethod otherwise. */
544
549
final def signature (implicit ctx : Context ): Signature =
545
550
if (lastDenot != null && (lastDenot.isCompleted || lastDenot.is(Method )))
Original file line number Diff line number Diff line change @@ -174,17 +174,13 @@ class TreeChecker extends Phase with SymTransformer {
174
174
175
175
/** The following invariant holds:
176
176
*
177
- * patBoundSyms.contains(sym) <=> patternBound( sym)
177
+ * patBoundSyms.contains(sym) <=> sym.isPatternBound
178
178
*/
179
- def patternBound (sym : Symbol )(implicit ctx : Context ): Boolean =
180
- (sym.isType && ! sym.isClass && sym.isOneOf(Case )) ||
181
- (sym.isTerm && sym.isOneOf(Case , butNot = Enum | Module ))
182
-
183
179
def withPatSyms [T ](syms : List [Symbol ])(op : => T )(implicit ctx : Context ): T = {
184
180
syms.foreach { sym =>
185
181
assert(
186
- patternBound( sym) ,
187
- " patBoundSyms.contains(sym) => patternBound( sym) is broken." +
182
+ sym.isPatternBound ,
183
+ " patBoundSyms.contains(sym) => sym.isPatternBound is broken." +
188
184
i " Pattern bound symbol $sym has incorrect flags: " + sym.flagsString + " , line " + sym.sourcePos.line
189
185
)
190
186
}
@@ -214,8 +210,8 @@ class TreeChecker extends Phase with SymTransformer {
214
210
215
211
if (! ctx.phase.patternTranslated)
216
212
assert(
217
- ! patternBound( sym) || patBoundSyms.contains(sym),
218
- i " patternBound( sym) => patBoundSyms.contains(sym) is broken, sym = $sym, line " + tree.sourcePos.line
213
+ ! sym.isPatternBound || patBoundSyms.contains(sym),
214
+ i " sym.isPatternBound => patBoundSyms.contains(sym) is broken, sym = $sym, line " + tree.sourcePos.line
219
215
)
220
216
}
221
217
You can’t perform that action at this time.
0 commit comments