Boo

Generic methods of generic types not being recognized correctly.

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.9
  • Fix Version/s: 0.9
  • Component/s: None
  • Labels:
    None
  • Environment:
    Windows XP, under SVN 3028
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

C# Test dll

public class Test<T>
{
	public static void Bar<U>(U u)
	{
	}
}

public interface IFace
{
}

Boo program:

class A:
	pass

x as IFace = null
Test[of A].Bar(x)

If A is replaced with object, it runs without error.

Here's the error:

Unhandled Exception: System.BadImageFormatException: An attempt was made to load
a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at TestModule.Main(String[] argv)

I tried looking at it with reflector, but reflector gets a null reference error. Here's the main function in ildasm:

.method private hidebysig static void  Main(string[] argv) cil managed
{
  .entrypoint
  // Code size       14 (0xe)
  .maxstack  1
  .locals init ([0] class [testlib]IFace x)
  IL_0000:  ldnull
  IL_0001:  stloc.0
  IL_0002:  ldloc.0
  IL_0003:  unbox.any  !!0
  IL_0008:  call       void class [testlib]Test`1<class A>::Bar<!!0>(!!0)
  IL_000d:  ret
} // end of method TestModule::Main

Reflector raises an exception after the second ! in IL_0003: unbox.any !!0
Assigning x to an instance of IFace doesn't change anything.

When you change IFace to a class instead of an interface, it raises a compile error:
test.boo(5,15): BCE0017: Boo.Lang.Compiler.CompilerError: The best overload for
the method 'Test[of T][A].Bar' is not compatible with the argument list '(IFace)
'.

When you try to specify the parameters explicitly as either class or interface, it gives another error:
test.boo(5,15): BCE0138: Boo.Lang.Compiler.CompilerError: 'Test[of T][A].Bar' is
not a generic definition.

Activity

Hide
Avishay Lavie added a comment -

Resolved in r3043.

Show
Avishay Lavie added a comment - Resolved in r3043.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: