Skip to content

Inspection for calls to Friend access members on late-bound objects #3116

@ThunderFrame

Description

@ThunderFrame

Given a class that is declared as:

Public Sub MyPublicMethod()
  Debug.Print Now(), "Public"
End Sub

Friend Sub MyFriendMethod()
  Debug.Print Now(), "Friend"
End Sub

VBA will allow the Friend members to be called, but only if the instance variable is early bound.

Sub test()

  Dim f As Foo
  Set f = New Foo
  f.MyPublicMethod
  f.MyFriendMethod
 
  With New Foo
    .MyPublicMethod
    .MyFriendMethod
  End With
 
  Dim v As Variant
  Set v = New Foo
  v.MyPublicMethod
  v.MyFriendMethod 'Runtime error 438 - Object doesn't support this property or method
  
  Dim o As Variant
  Set o = New Foo
  o.MyPublicMethod
  o.MyFriendMethod 'Runtime error 438 - Object doesn't support this property or method

End Sub

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-path-analysisInvolves simulating execution paths / interpreting the user code ..to an extent.enhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-inspectionsretriage-v3Issue is deferred until v3 is completed and may be entirely solved by the paradigm shift

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions