Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

VBNC substitutes generic type parameter for other types in generic methods #43

Open
rolfbjarne opened this issue May 22, 2018 · 0 comments

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented May 22, 2018

Submitted by a community member on 2016-05-01 12:10 UTC

When calling generic methods whose signatures contain generic types, VBNC gives an 'overload resolution failed' error although all actual parameters' types meet the corresponding formal parameters' types. The error message suggests that VBNC substitutes the generic type parameter of the method for the type arguments of the generic types that appear in the formal parameter list.

Trying to compile the attached code (vbnc Test.vb) results in the following error message (VBNC version 0.0.0.5943, Mono 3.8 - tarball):

/home/.../Test.vb (16,16) : error VBNC30518: Overload resolution failed because no accessible 'GenericTwo' can be called with these arguments:
'Private Sub GenericTwo(Arg As Long?)': Value of type 'Long?' cannot be converted to 'Test?'.

/home/.../Test.vb (17,18) : error VBNC30518: Overload resolution failed because no accessible 'GenericThree' can be called with these arguments:
'Private Sub GenericThree(Arg As System.Collections.Generic.List1<System.String>)': Value of type 'System.Collections.Generic.List1<System.String>' cannot be converted to 'System.Collections.Generic.List`1'.

Same VBNC version, but Mono version 4.0.1, gives the same error codes, but the error message is 'CHANGEME' then.

Expected behaviour: successful compilation.

Note that the call to GenericOne, whose signature doesn't contain any generic types, is accepted by the compiler as expected, while the calls to GenericTwo and GenericThree are only accepted if the argument given is Nothing. The error messages seem to indicate that the actual parameters in lines 16 and 17 (of type Nullable(Of Long) and List(Of String), respectively) have to be converted to Nullable(Of Test) and List(Of Test), respectively, which are the parameter types of the formal parameters of GenericTwo and GenericThree with the actual generic type argument of the method (Test) substituted for Long or String, respectively, instead for the formal generic type parameter T (which does not even appear among the formal parameters).

Operating system: Debian 8.4 (jessie) x86_64 Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz


Xamarin Bugzilla comment 1 by a community member on 2016-05-01 13:55 UTC

PS.
With VBNC 0.0.0.5917 and Mono 2.6.7 under Debian 6.0.5, the file compiles successfully.


Reference: https://bugzilla.xamarin.com/show_bug.cgi?id=40793

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant