Implicit Recursive Default Member Access

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.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

Class1 (ClassModule)
Public Function Foo() As Class2 Attibute Foo.VB_UserMemId = 0 Set Foo = New Class2 End Function
Class2 (ClassModule)
Public Function Bar() As Long Attibute Bar.VB_UserMemId = 0 Foo = 42 End Function
Module (StandardModule)
Public Sub DoSomething(ByVal arg As Class1) Dim bar As Variant bar = arg End Sub

This example should NOT trigger a result

Class1 (ClassModule)
Public Function Foo() As Class2 Attibute Foo.VB_UserMemId = 0 Set Foo = New Class2 End Function
Class2 (ClassModule)
Public Function Bar() As Long Attibute Bar.VB_UserMemId = 0 Foo = 42 End Function
Module (StandardModule)
Public Sub DoSomething(ByVal arg As Class1) Dim bar As Variant bar = arg.Foo().Bar() End Sub

Rubberduck.CodeAnalysis.Inspections.Concrete.ImplicitRecursiveDefaultMemberAccessInspection.cs (Prerelease-v2.5.9.6289)