Inspection Details

ImplicitRecursiveDefaultMemberAccess


Summary
Identifies the use of indexed default member accesses that require a recursive default member resolution.
Reasoning
Default member accesses hide away the actually called member. This is especially misleading if there is no indication in the expression that such a call is made and the final default member is not on the interface of the object itself. In particular, this can cause errors in which a member was forgotten to be called to go unnoticed.
The following code example(s) would trigger this inspection:
Class1

Public Function Foo() As Class2
    Attibute Foo.VB_UserMemId = 0
    Set Foo = New Class2
End Function

Class2

Public Function Bar() As Long
    Attibute Bar.VB_UserMemId = 0
    Foo = 42
End Function

Module

Public Sub DoSomething(ByVal arg As Class1)
    Dim bar As Variant
    bar = arg
End Sub

The following code example(s) would not trigger this inspection:
Class1

Public Function Foo() As Class2
    Attibute Foo.VB_UserMemId = 0
    Set Foo = New Class2
End Function

Class2

Public Function Bar() As Long
    Attibute Bar.VB_UserMemId = 0
    Foo = 42
End Function

Module

Public Sub DoSomething(ByVal arg As Class1)
    Dim bar As Variant
    bar = arg.Foo().Bar()
End Sub


Back to List