[nem-bug] [Nemerle 0000634]: Type inference error for interfaces of
value-type variables.
feedback at nemerle.org
feedback at nemerle.org
Mon May 22 18:06:06 CEST 2006
The following issue has been CLOSED
======================================================================
<http://nemerle.org/bugs/view.php?id=634>
======================================================================
Reported By: iae
Assigned To: nazgul
======================================================================
Project: Nemerle
Issue ID: 634
Category: Compiler (type engine)
Reproducibility: always
Severity: minor
Priority: normal
Status: closed
Resolution: not an issue
Fixed in Version:
======================================================================
Date Submitted: 03-10-2006 07:28 CET
Last Modified: 05-22-2006 18:06 CEST
======================================================================
Summary: Type inference error for interfaces of value-type
variables.
Description:
// error: there is no member named `ToInt32' in int with type ?
def _ = 1.ToInt32(null);
// error: there is no member named `ToInt32' in System.Double with type ?
def _ = 1.25.ToInt32(null);
// error: there is no member named `ToInt32' in E with type ?
// enum E { | First | Second }
def _ = E.First.ToInt32(null);
// OK.
// class C : IConvertible {...}
def _ = C().ToInt32(null);
======================================================================
----------------------------------------------------------------------
nazgul - 03-12-06 20:00
----------------------------------------------------------------------
This is because those classes use explicit interface implementation.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_13_4_1.asp
We follow the same rules as in C#, that is in order to call interface
method, it must be called on interface object. It works this way, because
you can implement two interfaces with the same method signature and it
wouldn't be possible to distinguish which of them is called through
derived class:
interface A {
foo () : void;
}
inteface B {
foo () : void
}
class C : A, B {
foo1 () : void implements A.foo() { }
foo2 () : void implements B.foo() { }
}
So, this is by design :/
Use
def _ = (1 : IConvertible).ToInt32 (null);
(it is a compile-time upcast)
Issue History
Date Modified Username Field Change
======================================================================
03-10-06 07:28 iae New Issue
03-12-06 20:00 nazgul Status new => resolved
03-12-06 20:00 nazgul Resolution open => not an issue
03-12-06 20:00 nazgul Assigned To => nazgul
03-12-06 20:00 nazgul Note Added: 0001121
03-12-06 20:00 nazgul Description Updated
05-22-06 18:06 nazgul Status resolved => closed
======================================================================
More information about the bugs
mailing list