@@ -592,17 +592,17 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
592592 or
593593 // creation of an optional via implicit conversion,
594594 // i.e. from `f(x)` where `x: T` into `f(.some(x))` where the context `f` expects a `T?`.
595- exists ( InjectIntoOptionalExpr e , OptionalSomeDecl someDecl |
595+ exists ( InjectIntoOptionalExpr e |
596596 e .convertsFrom ( node1 .asExpr ( ) ) and
597597 node2 = node1 and // HACK: we should ideally have a separate Node case for the (hidden) InjectIntoOptionalExpr
598- c . isSingleton ( any ( Content :: EnumContent ec | ec . getParam ( ) = someDecl . getParam ( 0 ) ) )
598+ c instanceof OptionalSomeContentSet
599599 )
600600 or
601601 // creation of an optional by returning from an optional initializer (`init?`)
602- exists ( ConstructorDecl init , OptionalType initRetType , OptionalSomeDecl someDecl |
602+ exists ( ConstructorDecl init , OptionalType initRetType |
603603 node1 .asExpr ( ) .( CallExpr ) .getStaticTarget ( ) = init and
604604 node2 = node1 and // HACK: again, we should ideally have a separate Node case here, and not reuse the CallExpr
605- c . isSingleton ( any ( Content :: EnumContent ec | ec . getParam ( ) = someDecl . getParam ( 0 ) ) ) and
605+ c instanceof OptionalSomeContentSet and
606606 init .getInterfaceType ( ) .( FunctionType ) .getResult ( ) .( FunctionType ) .getResult ( ) = initRetType
607607 )
608608 or
@@ -649,10 +649,10 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
649649 )
650650 or
651651 // read of an optional .some member via `let x: T = y: T?` pattern matching
652- exists ( OptionalSomePattern pat , OptionalSomeDecl someDecl |
652+ exists ( OptionalSomePattern pat |
653653 node1 .asPattern ( ) = pat and
654654 node2 .asPattern ( ) = pat .getSubPattern ( ) and
655- c . isSingleton ( any ( Content :: EnumContent ec | ec . getParam ( ) = someDecl . getParam ( 0 ) ) )
655+ c instanceof OptionalSomeContentSet
656656 )
657657}
658658
@@ -672,15 +672,17 @@ predicate clearsContent(Node n, ContentSet c) {
672672predicate expectsContent ( Node n , ContentSet c ) { none ( ) }
673673
674674/**
675- * The global singleton `Optional.some` enum element .
675+ * The global singleton `Optional.some` content set .
676676 */
677- private class OptionalSomeDecl extends EnumElementDecl {
678- OptionalSomeDecl ( ) {
679- exists ( EnumDecl enum |
680- this .getName ( ) = "some" and
681- this .getDeclaringDecl ( ) = enum and
682- enum .getName ( ) = "Optional" and
683- enum .getModule ( ) .getName ( ) = "Swift"
677+ private class OptionalSomeContentSet extends ContentSet {
678+ OptionalSomeContentSet ( ) {
679+ exists ( EnumDecl optional , EnumElementDecl some |
680+ some .getDeclaringDecl ( ) = optional and
681+ some .getName ( ) = "some" and
682+ optional .getName ( ) = "Optional" and
683+ optional .getModule ( ) .getName ( ) = "Swift"
684+ |
685+ this .isSingleton ( any ( Content:: EnumContent ec | ec .getParam ( ) = some .getParam ( 0 ) ) )
684686 )
685687 }
686688}
0 commit comments