[Bug] Can't call an extension method for an Object
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
I have these extensions:
```VB.NET
Imports System.Runtime.CompilerServices
Module Extensions
Public Sub Print(ByVal aString As String)
Console.WriteLine(aString)
End Sub
Public Function IsSomething(ByVal o As String) As Boolean
Return o IsNot Nothing
End Function
Public Function IsSomething(ByVal o As Object) As Boolean
Return o IsNot Nothing
End Function
End Module
```
now, I have this code:
```VB.NET
Dim o As Object = ""
If o.IsSomething Then
End If
```
It gives me the runtime exception:
> Public member 'IsSomething' on type 'String' not found
Why can't vb use the extension Object.IsSomething or String.IsSomething?
Note that this code works:
```VB.NET
Dim o As String = ""
If o.IsSomething Then
End If
```
The only code that works with Object is this:
```VB.NET
Dim o As Object = Nothing
If o?.IsSomething Then
End If
```
I can accept that extension methods don't work with boxed values because of late binding, but why doesn't VB use the extension for the object and compile `O.IsSomething`: to `IsSomething(O)`?
I think this is a bug that needs to be fixed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.