Index: C:/boo-ssh/src/Boo.Lang.Compiler/Steps/ProcessMethodBodies.cs =================================================================== --- C:/boo-ssh/src/Boo.Lang.Compiler/Steps/ProcessMethodBodies.cs (revision 2036) +++ C:/boo-ssh/src/Boo.Lang.Compiler/Steps/ProcessMethodBodies.cs (working copy) @@ -2023,6 +2023,18 @@ } } } + foreach (IEntity entity in toType.GetMembers()) + { + if (EntityType.Method == entity.EntityType && + name == entity.Name) + { + IMethod method = (IMethod)entity; + if (IsConversionOperator(method, fromType, toType)) + { + return method; + } + } + } fromType = fromType.BaseType; if (null == fromType) break; } Index: C:/boo-ssh/tests/testcases/errors/BCE0022-10.boo =================================================================== --- C:/boo-ssh/tests/testcases/errors/BCE0022-10.boo (revision 0) +++ C:/boo-ssh/tests/testcases/errors/BCE0022-10.boo (revision 0) @@ -0,0 +1,18 @@ +""" +BCE0022-10.boo(13,20): BCE0022: Cannot convert 'System.IntPtr' to 'System.Runtime.InteropServices.GCHandle'. +""" +import System +import System.Runtime.InteropServices + +obj = object() + +//succeeds: +ptr as IntPtr = cast(IntPtr, GCHandle.Alloc( obj )) + +//should fail because op_Explicit requires explicit cast: +gch2 as GCHandle = ptr + +gch2.Free() + +print "test should have failed" + Index: C:/boo-ssh/tests/testcases/regression/BOO-651-1.boo =================================================================== --- C:/boo-ssh/tests/testcases/regression/BOO-651-1.boo (revision 0) +++ C:/boo-ssh/tests/testcases/regression/BOO-651-1.boo (revision 0) @@ -0,0 +1,22 @@ +""" +test passed +""" +import System +import System.Runtime.InteropServices + +obj = object() + +//succeeds: +ptr as IntPtr = cast(IntPtr, GCHandle.Alloc( obj )) + +//previously failed: +gch = cast(GCHandle, ptr) + +//Should fail because op_Explicit requires explicit cast: +//Tested in ../errors/BCE0022-10.boo +//gch2 as GCHandle = ptr + +gch.Free() + +print "test passed" +