Skip to content

Commit 14ad4d9

Browse files
committed
fixed AsTypeName of optional parameters with a default value
1 parent 7d4431c commit 14ad4d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ private Declaration CreateDeclaration(
185185
{
186186
var argContext = (VBAParser.ArgContext)context;
187187
var isOptional = argContext.OPTIONAL() != null;
188+
if (isOptional)
189+
{
190+
// if parameter is optional, asTypeName may contain the default value
191+
var complexType = asTypeContext.type().complexType();
192+
if (complexType != null && complexType.expression() is VBAParser.RelationalOpContext)
193+
{
194+
asTypeName = complexType.expression().GetChild(0).GetText();
195+
}
196+
}
197+
188198
var isByRef = argContext.BYREF() != null;
189199
var isParamArray = argContext.PARAMARRAY() != null;
190200
result = new ParameterDeclaration(

0 commit comments

Comments
 (0)