History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-777
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Avishay Lavie
Reporter: Avishay Lavie
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Boo

Consuming generic methods

Created: 26/Oct/06 07:13 PM   Updated: 25/Jul/07 02:41 AM
Component/s: Parser, Compiler
Affects Version/s: None
Fix Version/s: 0.7.7

Time Tracking:
Issue & Sub-Tasks
Issue Only
Not Specified

File Attachments: 1. Text File BOO-777-1.diff (41 kb)
2. Text File BOO-777-2.diff (42 kb)

Issue Links:
Related
 
dependent
 

Sub-Tasks  All   Open   

 Description  « Hide
ints = List of int()
ints.Add(1)
ints.Add(2)
ints.Add(3)

strings = ints.ConvertAll of string( {i as int | return i.ToString("g")} )

and then, using type inference, just:

strings = ints.ConvertAll( {i as int | return i.ToString("g")} )

I don't think the parser even knows about generic method invocations.
The syntax gets a little ugly when you have more than one generic parameter.
Consider System.Array.ConvertAll of int, of string(ints, {i as int | return i.ToString("g")}) for example.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Avishay Lavie - 28/Feb/07 12:24 AM
Scheduled for 0.7.7. We may not support defining new generic types, but we should at the very least be able to consume all forms of generics, including generic methods.

Avishay Lavie - 02/Apr/07 05:43 PM
Attached patch (BOO-777-1.diff) including simple testcases.

I can't commit this cause way too many unit tests are failing; however they all fail on a clean checkout as well, so one can never know.

Please, kind people, take this patch and treat it with warmth and kindness. Test it on thy windows boxen and if found worthy, tell me and I'll commit it (or you can commit yourself, whatever).


Avishay Lavie - 03/Apr/07 09:52 AM
Added second patch, since first one seems corrupted.

Max Bolingbroke - 03/Apr/07 06:35 PM
Had considerable difficulty applying the patch (both have the same problem):
  • Needed to remove leading BOMs from MixedGenericType and the MixedGenericType section of the patch before TortoiseSVN would apply it
  • Had to then remove leading junk character (the question mark) from MixedGenericMethod and one other (can't remember, possible MixedGenericType) before the project would compile

This may be a TortoiseSVN bug, it looks to my untrained eye at least that your patches are valid.


Max Bolingbroke - 03/Apr/07 06:50 PM
OK, I've run the test suite over a copy of revision 2444 with this patch, and I get exactly two failures, both in BooCompiler.Tests:

1) BooCompiler.Tests.LocalizationTestCase.TestPtBrCulture :
String lengths are both 22.
Strings differ at index 0.
expected: <"Token inesperado: foo.">
but was: <"Unexpected token: foo.">
------------^
at BooCompiler.Tests.LocalizationTestCase.AssertCultureDependentMessage(Strin
g message, CultureInfo culture)
at BooCompiler.Tests.LocalizationTestCase.TestPtBrCulture()

2) BooCompiler.Tests.RegressionTestFixture.BOO_748_1 : E:\Programming\Checkouts\
Boo-Trunk-777\tests\testcases\regression\BOO-748-1.boo: BCE0011: An error occurr
ed during the execution of the step 'Boo.Lang.Compiler.Steps.RunAssembly': 'Coul
d not load file or assembly 'testcase, Version=0.0.0.0, Culture=neutral, PublicK
eyToken=null' or one of its dependencies. The system cannot find the file specif
ied.'.
BCW0000: WARNING: Could not start peverify.exe
at BooCompiler.Tests.AbstractCompilerTestCase.Run(String stdin, CompilerConte
xt& context)
at BooCompiler.Tests.AbstractCompilerTestCase.RunAndAssert()
at BooCompiler.Tests.AbstractCompilerTestCase.RunCompilerTestCase(String name
)
at BooCompiler.Tests.RegressionTestFixture.BOO_748_1()

I don't know what is causing the first, but the second one could be because 748_1 does not define an expectation in a """blah""" block at the top of the file. At least, every other regression test I've looked at has one of these.


Max Bolingbroke - 03/Apr/07 06:55 PM
OK, maybe not . I ran the test suite on a clean checkout of 2444 and got no failures at all!

Avishay Lavie - 06/Apr/07 08:25 AM
Fixed in revision 2446.
Type inference for generic methods (BOO-814) is not yet implemented, however.