(ref.#2382)
Given this code:
Sub DoSomething()
Dim foo As Object
Set foo = New Something
End Sub
When the LHS type mismatches the RHS type of a SetStmt, we should issue an inspection result. This one has a few subtleties though:
Object or 'Variant', Rubberduck should recommend using the RHS type instead.Something implements ISomething and IFoo then we should suggest declaring foo As ISomething or foo As IFoo.To take this another step, I'd personally like to see RD recommend using New in cases like this...
Sub DoSomething()
Dim foo As Bar
Set foo = CreateObject("SomeApp.Bar")
End Sub
...with a quick-fix to Set foo = New SomeApp.Bar.
Most helpful comment
To take this another step, I'd personally like to see RD recommend using
Newin cases like this......with a quick-fix to
Set foo = New SomeApp.Bar.