Bug 40793 - VBNC substitutes generic type parameter for other types in generic methods
Summary: VBNC substitutes generic type parameter for other types in generic methods
Status: RESOLVED UPSTREAM
Alias: None
Product: Compilers
Classification: Mono
Component: VisualBasic ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-05-01 12:10 UTC by addrgd
Modified: 2018-05-22 12:32 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
This file should compile but does not. (972 bytes, text/plain)
2016-05-01 12:10 UTC, addrgd
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description addrgd 2016-05-01 12:10:36 UTC
Created attachment 15876 [details]
This file should compile but does not.

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.List`1<System.String>)': Value of type 'System.Collections.Generic.List`1<System.String>' cannot be converted to 'System.Collections.Generic.List`1<Test>'.

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
Comment 1 addrgd 2016-05-01 13:55:00 UTC
PS.
With VBNC 0.0.0.5917 and Mono 2.6.7 under Debian 6.0.5, the file compiles successfully.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2018-05-22 12:32:56 UTC
Moved to: https://github.com/mono/mono-basic/issues/43