Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 "Change signature" refactoring fails

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
MichaelH Posted - Oct 01 2018 : 06:35:36 AM

class Foo
{
  public:
    int doFoo(int bar, bool baz) { return (baz ? 42 : bar); };
}

class SubFoo : public Foo
{
  public:
    int doFoo(int bar) { return Foo::doFoo(bar, false); };
}


Attempting to refactor the doFoo() function via "Change signature" (switching the places of the 'int bar' and 'bool baz' parameters) the Foo class leads to unexpected results and an error:


class Foo
{
  public:
    // All good & well here
    int doFoo(bool baz, int bar) { return (baz ? 42 : bar); };
}

class SubFoo : public Foo
{
  public:
    // Error here: SubFoo::doFoo() got the 'bool baz' parameter from Foo:doFoo()
    int doFoo(bool baz, int bar) { return Foo::doFoo(false, bar); };
}


Fortunately Visual assists normally warns that something went wrong ("Visual Assist failed to modify one or more files...") - even though the error message is incorrect too (it did change the file, but incorrectly)

System Info:
Visual Studio 2015 Update 3, C++
License: [email protected] (2-user license) Support ends 2019.06.14
VA_X.dll file version 10.9.2283.2 built 2018.08.02
DevEnv.exe version 14.0.25420.1 Professional
msenv.dll version 14.0.25431.1
Comctl32.dll version 6.10.17134.285
Windows 10 10.0 Build 17134.285
8 processors (x86-64, WOW64)
Language info: 1252, 0x407
3   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 01 2018 : 11:19:22 AM
Ah, I see more clearly what is going wrong here. I have put in a bug report for this:

case=119722

Thank you for the clear explanation. Sometimes I focus on the wrong feature in the code sample, and go off in the wrong direction
MichaelH Posted - Oct 01 2018 : 09:02:20 AM
My apologies feline, I must have accidently removed the second parameter in the SubFoo::doFoo() function while prettying-up the code (As you may have guessed, the code above is not the code that made me run across the issue initially)

I've updated my original post, and double-checked that the code compiles (and that the error issue persists) - unfortunatly it did.
As you can see, in SubFoo::doFoo() the 'return Foo::doFoo(bar, false);' is properly swapped to `return Foo::doFoo(false, bar)` - but still, the parameter list for SubFoo::doFoo() is expanded from 'SubFoo::doFoo(int bar)' to 'SubFoo::doFoo(bool baz, int bar)'
feline Posted - Oct 01 2018 : 08:03:29 AM
Have you tried compiling your sample code? I ask because in the SubFoo class, inside the doFoo function body, you only pass one parameter to the parent class function call, but two parameters are required. So if VA is going to try to update this correctly, we will have problems, since the code is not right to start with.

It raises an interesting point about error checking, and allowing the Change Signature to run when there is a function call that we won't be able to update correctly.

I have put in a feature request to check the number of parameters is correct in all calls we want to update before trying to do the updates:

case=119714

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000