Skip to content

Commit 57e2a96

Browse files
committed
Address review comment
1 parent e4238e6 commit 57e2a96

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/AstPluginSwift.qll‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module;
33

44
private import unified
55
private import AstPlugin
6-
private import codeql.unified.internal.typeinference.TypeMention
7-
private import codeql.unified.internal.typeinference.TypeInferencePluginSwift
86

97
private predicate structHasParameterForField(
108
ConstructorDeclaration cd, VariableDeclaration decl, int i, string name, boolean hasDefault
@@ -19,8 +17,11 @@ private predicate structHasParameterForField(
1917
// if `decl` has an initializer or `Optional` type then the parameter has a default value
2018
decl.hasModifier("var") and
2119
if
22-
exists(decl.getValue()) or
23-
decl.getType().(TypeMention).getType() instanceof OptionalType
20+
exists(decl.getValue())
21+
or
22+
// we could make this more precise using static name binding, but for now we
23+
// use a simpler approach to avoid the dependency on static name binding
24+
decl.getType().(GenericTypeExpr).getBase().(Identifier).getValue() = "Optional"
2425
then hasDefault = true
2526
else hasDefault = false
2627
or

0 commit comments

Comments
 (0)