@@ -244,15 +244,6 @@ public struct SmallProjectionPath : Hashable, CustomStringConvertible, NoReflect
244
244
}
245
245
}
246
246
247
- /// Returns true if the path does not have any class projections.
248
- /// For example:
249
- /// returns true for `v**`
250
- /// returns false for `c0`
251
- /// returns false for `**` (because '**' can have any number of class projections)
252
- public var hasNoClassProjection : Bool {
253
- return matches ( pattern: Self ( . anyValueFields) )
254
- }
255
-
256
247
/// Returns true if the path has at least one class projection.
257
248
/// For example:
258
249
/// returns false for `v**`
@@ -268,6 +259,15 @@ public struct SmallProjectionPath : Hashable, CustomStringConvertible, NoReflect
268
259
}
269
260
}
270
261
262
+ /// Returns true if the path may have a class projection.
263
+ /// For example:
264
+ /// returns false for `v**`
265
+ /// returns true for `c0`
266
+ /// returns true for `**` (because '**' can have any number of class projections)
267
+ public var mayHaveClassProjection : Bool {
268
+ return !matches( pattern: Self ( . anyValueFields) )
269
+ }
270
+
271
271
/// Pops all value field components from the beginning of the path.
272
272
/// For example:
273
273
/// `s0.e2.3.c4.s1` -> `c4.s1`
@@ -679,17 +679,18 @@ extension SmallProjectionPath {
679
679
}
680
680
681
681
func predicates( ) {
682
- testPredicate ( " v** " , \. hasNoClassProjection, expect: true )
683
- testPredicate ( " c0 " , \. hasNoClassProjection, expect: false )
684
- testPredicate ( " 1 " , \. hasNoClassProjection, expect: true )
685
- testPredicate ( " ** " , \. hasNoClassProjection, expect: false )
686
-
687
682
testPredicate ( " v** " , \. hasClassProjection, expect: false )
688
683
testPredicate ( " v**.c0.s1.v** " , \. hasClassProjection, expect: true )
689
684
testPredicate ( " c0.** " , \. hasClassProjection, expect: true )
690
685
testPredicate ( " c0.c1 " , \. hasClassProjection, expect: true )
691
686
testPredicate ( " ct " , \. hasClassProjection, expect: true )
692
687
testPredicate ( " s0 " , \. hasClassProjection, expect: false )
688
+
689
+ testPredicate ( " v** " , \. mayHaveClassProjection, expect: false )
690
+ testPredicate ( " c0 " , \. mayHaveClassProjection, expect: true )
691
+ testPredicate ( " 1 " , \. mayHaveClassProjection, expect: false )
692
+ testPredicate ( " ** " , \. mayHaveClassProjection, expect: true )
693
+
693
694
}
694
695
695
696
func testPredicate( _ pathStr: String , _ property: ( SmallProjectionPath ) -> Bool , expect: Bool ) {
0 commit comments