Consider a MyForm
class that contains a shadowed implementation of Show()
. It also contains a CreateForm()
method, which accepts an instance of the form and calls the shadowed sub:
Public Class MyForm
Inherits Form
Public Shadows Sub Show()
MessageBox.Show("Shadowed implementation called!")
End Sub
End Class
...
Public Sub CreateForm(ByVal childForm As MyForm)
childForm.MdiParent = Me
childForm.Show()
childForm.Focus()
End Sub
When called with CreateForm(New MyForm())
, the shadowed implementation of Show()
is correctly called. Now consider the following generic implementation:
Public Sub CreateForm(Of T As Form)(ByVal childForm As T)
childForm.MdiParent = Me
childForm.Show()
childForm.Focus()
End Sub
Called with CreateForm(Of MyForm)(New MyForm())
, this strongly-typed generic method never invokes the shadowed method.
Is this a bug, or am I missing something?