PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Template parameter deduction and with overloaded methods.
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Template parameter deduction and with overloaded methods.
![]() |
Template parameter deduction and with overloaded methods. |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi All,
I have an overloaded generic method anmed "Foo": Class Test Class Xox(Of T) End Class Class Lulli(Of T) Inherits Xox(Of T) End Class Overloads Shared Function Foo(Of T, Iter As Xox(Of T))(ByVal x As Iter, ByVal tt As T) As Iter Return x End Function Overloads Shared Function Foo(Of T)(ByVal l As Lulli(Of T), ByVal tt As T) As Lulli(Of T) Return l End Function Shared Sub Main() Dim xox As New Xox(Of Integer) Dim lulli As New Lulli(Of Integer) Dim xx As Xox(Of Integer) = Foo(xox, 42) ' gives a BC30521 error 'Dim ll As Lulli(Of Integer) = Foo(lulli, 42) End Sub End Class When I try to access the second overload, the compiler does not seem to be able to find the correct method (BC30521). Explicitly declaring the generic parameters solves the problem: Dim ll As Lulli(Of Integer) = _ Foo(Of Integer, Lulli(Of Integer))(lulli, 42) It look like the compiler can't deduct the generic arguments to find the correct overload. As this works from C#, I'm asking myself if this "as designed" or a bug of the VB compiler? TIA, Andy ---- To email me directly, please remove the *NO*SPAM* parts below: *NO*SPAM*xmen40@*NO*SPAM*gmx.net |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Andreas,
"Andreas Mueller" <me@privacy.net> schrieb: > I have an overloaded generic method anmed "Foo": > > Class Test > Class Xox(Of T) > End Class > Class Lulli(Of T) > Inherits Xox(Of T) > End Class > > Overloads Shared Function Foo(Of T, Iter As Xox(Of T))(ByVal x As > Iter, ByVal tt As T) As Iter > Return x > End Function > Overloads Shared Function Foo(Of T)(ByVal l As Lulli(Of T), ByVal tt > As T) As Lulli(Of T) > Return l > End Function > Shared Sub Main() > Dim xox As New Xox(Of Integer) > Dim lulli As New Lulli(Of Integer) > > Dim xx As Xox(Of Integer) = Foo(xox, 42) > > ' gives a BC30521 error > 'Dim ll As Lulli(Of Integer) = Foo(lulli, 42) > End Sub > End Class > > When I try to access the second overload, the compiler does not seem to be > able to find the correct method (BC30521). Explicitly declaring the > generic parameters solves the problem: > > Dim ll As Lulli(Of Integer) = _ > Foo(Of Integer, Lulli(Of Integer))(lulli, 42) > > It look like the compiler can't deduct the generic arguments to find the > correct overload. > > As this works from C#, I'm asking myself if this "as designed" or a bug of > the VB compiler? I think this is a bug, because the chapter about overload resolution in the language specification states that two methods with the same signature due to type parameters should choose the less generic overload. I suggest to file a bug report at <URL:http://lab.msdn.microsoft.com/productfeedback/>. If you do not file the bug in the next few days I'll submit a bug report on this issue. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Herfried K. Wagner [MVP] wrote:
> Andreas, > > "Andreas Mueller" <me@privacy.net> schrieb: > >> I have an overloaded generic method anmed "Foo": >> >> Class Test >> Class Xox(Of T) >> End Class >> Class Lulli(Of T) >> Inherits Xox(Of T) >> End Class >> >> Overloads Shared Function Foo(Of T, Iter As Xox(Of T))(ByVal x As >> Iter, ByVal tt As T) As Iter >> Return x >> End Function >> Overloads Shared Function Foo(Of T)(ByVal l As Lulli(Of T), ByVal >> tt As T) As Lulli(Of T) >> Return l >> End Function >> Shared Sub Main() >> Dim xox As New Xox(Of Integer) >> Dim lulli As New Lulli(Of Integer) >> >> Dim xx As Xox(Of Integer) = Foo(xox, 42) >> >> ' gives a BC30521 error >> 'Dim ll As Lulli(Of Integer) = Foo(lulli, 42) >> End Sub >> End Class >> >> When I try to access the second overload, the compiler does not seem >> to be able to find the correct method (BC30521). Explicitly declaring >> the generic parameters solves the problem: >> >> Dim ll As Lulli(Of Integer) = _ >> Foo(Of Integer, Lulli(Of Integer))(lulli, 42) >> >> It look like the compiler can't deduct the generic arguments to find >> the correct overload. >> >> As this works from C#, I'm asking myself if this "as designed" or a >> bug of the VB compiler? > > > I think this is a bug, because the chapter about overload resolution in > the language specification states that two methods with the same signature > due to type parameters should choose the less generic overload. > > I suggest to file a bug report at > <URL:http://lab.msdn.microsoft.com/productfeedback/>. If you do not > file the bug in the next few days I'll submit a bug report on this issue. > That's what I thought. Logged it, DID FDBK42807 CU, Andy -- To email me directly, please remove the *NO*SPAM* parts below: *NO*SPAM*xmen40@*NO*SPAM*gmx.net |
|
|
|
#4 |
|
Guest
Posts: n/a
|
"Andreas Mueller" <me@privacy.net> schrieb:
> Logged it, DID FDBK42807 It seems that you have forgotten to upload the attachment. <URL:http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=07751a75-a700-45b1-af3b-8751afcc7779> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Herfried K. Wagner [MVP] wrote:
> "Andreas Mueller" <me@privacy.net> schrieb: > >> Logged it, DID FDBK42807 > > > It seems that you have forgotten to upload the attachment. > > <URL:http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=07751a75-a700-45b1-af3b-8751afcc7779> > > ok, should be in now. looks like I just browsed for it and didn't hit the attach button :-( -- To email me directly, please remove the *NO*SPAM* parts below: *NO*SPAM*xmen40@*NO*SPAM*gmx.net |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Andreas,
"Andreas Mueller" <me@privacy.net> schrieb: >>> Logged it, DID FDBK42807 >> >> It seems that you have forgotten to upload the attachment. >> >> <URL:http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=07751a75-a700-45b1-af3b-8751afcc7779> > ok, should be in now. looks like I just browsed for it and didn't hit the > attach button :-( Thanks very much. I have validated the bug and voted for it. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

