Skip to content

Unexpected Set Assignment with incompatible object type #5890

@Energeer

Description

@Energeer

Rubberduck version information
The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:

Rubberduck version 2.5.2.5906
Operating System: Microsoft Windows NT 10.0.19042.0 x64
Host Product: Microsoft Office x64
Host Version: 16.0.14430.20306
Host Executable: EXCEL.EXE

Description
Rubberduck shows a code inspection for Set Assignment with incompatible object type - I do not think it is applicable in this case.

The Create function of the predeclaredID of ThingFactory produces an IThingFactory object, Rubberduck inspection appears to think it produces an IThing object. The IThingFactory interface Create function produces an IThing object, but this is not being called from the predeclared ID.

To Reproduce
Steps to reproduce the behavior:

IThing.cls
'@Interface

Thing.cls
Implements IThing

IThingFactory.cls

'@Interface

Option Explicit

Public Function Create() As IThing
End Function

ThingFactory.cls

'@PredeclaredId

Option Explicit

Implements IThingFactory

Public Function Create() As IThingFactory

End Function

Private Function IThingFactory_Create() As IThing
    
End Function

Module.bas

Public Sub Example()
    Dim Factory As IThingFactory
    Set Factory = ThingFactory.Create
End Sub

Expected behavior
Not to see the 'Set Assignment with incompatible object type' inspection.

Additional context
I'm not massively experienced in VBA so its possible the inspection is right for some reason I'm not aware. Rubberduck is a great tool and has helped me a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIdentifies work items for known bugsfeature-inspectionsinspection-false-positiveA bug where an inspection result appears, even though it is incorrect.resolverIssue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees.

    Type

    No type

    Projects

    Status

    Backlog | Inspections

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions