@@ -271,6 +271,8 @@ module AssignableInternal {
271271 def = TPatternDefinition ( result )
272272 or
273273 def = TAssignOperationDefinition ( result )
274+ or
275+ def = TParameterDefaultDefinition ( _, result )
274276 }
275277
276278 /** A local variable declaration at the top-level of a pattern. */
@@ -308,10 +310,17 @@ module AssignableInternal {
308310 exists ( Callable c | p = c .getAParameter ( ) |
309311 c .hasBody ( )
310312 or
311- // Same as `c.(Constructor).hasInitializer()`, but avoids negative recursion warning
312- c .getAChildExpr ( ) instanceof @constructor_init_expr
313+ c .( Constructor ) .hasInitializer ( )
313314 )
314315 } or
316+ TParameterDefaultDefinition ( Parameter p , Expr default ) {
317+ exists ( Callable c | p = c .getAParameter ( ) |
318+ c .hasBody ( )
319+ or
320+ c .( Constructor ) .hasInitializer ( )
321+ ) and
322+ default = p .getDefaultValue ( )
323+ } or
315324 TAddressOfDefinition ( AddressOfExpr aoe ) or
316325 TPatternDefinition ( TopLevelPatternDecl tlpd ) or
317326 TAssignOperationDefinition ( AssignOperation ao ) {
@@ -350,6 +359,8 @@ module AssignableInternal {
350359 any ( AssignableDefinitions:: PatternDefinition pd | result = pd .getDeclaration ( ) .getVariable ( ) )
351360 or
352361 def = any ( AssignableDefinitions:: InitializerDefinition init | result = init .getAssignable ( ) )
362+ or
363+ def = TParameterDefaultDefinition ( result , _)
353364 }
354365
355366 // Not defined by dispatch in order to avoid too conservative negative recursion error
@@ -493,11 +504,6 @@ class AssignableDefinition extends TAssignableDefinition {
493504 exists ( Ssa:: ExplicitDefinition def | result = def .getAFirstReadAtNode ( cfn ) |
494505 this = def .getADefinition ( )
495506 )
496- or
497- exists ( Ssa:: ImplicitParameterDefinition def | result = def .getAFirstReadAtNode ( cfn ) |
498- this .( AssignableDefinitions:: ImplicitParameterDefinition ) .getParameter ( ) =
499- def .getParameter ( )
500- )
501507 )
502508 }
503509
@@ -689,7 +695,33 @@ module AssignableDefinitions {
689695
690696 override string toString ( ) { result = p .toString ( ) }
691697
692- override Location getLocation ( ) { result = this .getTarget ( ) .getLocation ( ) }
698+ override Location getLocation ( ) { result = p .getLocation ( ) }
699+ }
700+
701+ /**
702+ * A default value assigned to a parameter.
703+ */
704+ class ParameterDefaultDefinition extends AssignableDefinition , TParameterDefaultDefinition {
705+ Parameter p ;
706+ Expr default ;
707+
708+ ParameterDefaultDefinition ( ) { this = TParameterDefaultDefinition ( p , default ) }
709+
710+ /** Gets the underlying parameter. */
711+ Parameter getParameter ( ) { result = p }
712+
713+ /** Gets the default value expression for the parameter. */
714+ Expr getDefaultValue ( ) { result = default }
715+
716+ override Expr getSource ( ) { result = default }
717+
718+ override Expr getElement ( ) { result = default }
719+
720+ override Callable getEnclosingCallable ( ) { result = p .getCallable ( ) }
721+
722+ override string toString ( ) { result = p .toString ( ) + " = ..." }
723+
724+ override Location getLocation ( ) { result = default .getLocation ( ) }
693725 }
694726
695727 /**
0 commit comments