tdf#118544 set correct type for optional parameter

Change-Id: Id8840431b9dc1f1e97882c675ebfc6456e33d953
Reviewed-on: https://gerrit.libreoffice.org/77684
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/basic/qa/basic_coverage/test_optional_paramter_type.vb b/basic/qa/basic_coverage/test_optional_paramter_type.vb
new file mode 100755
index 0000000..37198ea
--- /dev/null
+++ b/basic/qa/basic_coverage/test_optional_paramter_type.vb
@@ -0,0 +1,33 @@
REM  *****  BASIC  *****

Option Compatible



Function doUnitTest() As Integer

    doUnitTest = 0

    If CheckType1(32) = 0 Then

        Exit Function

    End If

    If CheckType2(32) = 0 Then

        Exit Function

    End If

    If CheckType2() = 0 Then

        Exit Function

    End If

    doUnitTest = 1

End Function



Function CheckType1(x As Integer) As Integer

    If TypeName(x) = "Integer" Then

         CheckType1 = 1

    Else

         CheckType1 = 0

    End If

End Function





Function CheckType2(Optional y As Integer = 32 ) As Integer

    If TypeName(y) = "Integer" Then

        CheckType2 = 1

    Else

        CheckType2 = 0

    End If

End Function
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
old mode 100644
new mode 100755
index 74fe533b..59daf15
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -4040,7 +4040,7 @@
                    if( nDefaultId > 0 )
                    {
                        OUString aDefaultStr = pImg->GetString( nDefaultId );
                        p = new SbxVariable();
                        p = new SbxVariable(pParam-> eType);
                        p->PutString( aDefaultStr );
                        refParams->Put( p, i );
                    }