[nem-bug] [Nemerle 0000655]: Implicit cast not works for generic
structs if converted operand has generic parameter type
feedback at nemerle.org
feedback at nemerle.org
Tue Apr 11 11:20:18 CEST 2006
The following issue has been SUBMITTED.
======================================================================
<http://nemerle.org/bugs/view.php?id=655>
======================================================================
Reported By: OysterDva
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 655
Category: Compiler
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 04-11-2006 11:20 CEST
Last Modified: 04-11-2006 11:20 CEST
======================================================================
Summary: Implicit cast not works for generic structs if
converted operand has generic parameter type
Description:
The following code will not compile:
interface IFoo {}
struct Bar1['a] where 'a : IFoo
{
static public @:(_ : 'a) : Bar1['a]
{
Bar1()
}
}
struct Bar2 : IFoo {}
def bar : Bar1.[IFoo] = Bar2()
The error message will be: "expected Bar1[IFoo], got Bar2 in type-enforced
expression: Bar2 is not a subtype of Bar1 [simple require]".
However, I'm expecting that implicit cast operator can be used here. For
example, the same C# code compiles without any problems:
interface IFoo {}
struct Bar1<T> where T : IFoo
{
static public implicit operator Bar1<T>(T obj)
{
return new Bar1<T>();
}
}
struct Bar2 : IFoo {}
class Program
{
static void Main(string[] args)
{
Bar1<IFoo> bar = new Bar2();
}
}
PS: Actually I want to use the following code:
interface IFoo {}
struct Bar1['a] where 'a : IFoo
{
static public @:['b](_ : 'b) : Bar1['a] where 'b : IFoo
{
Bar1()
}
}
struct Bar2 : IFoo {}
def bar : Bar1.[IFoo] = Bar2()
Which is seem to be valid but not compiles for the same reason.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
04-11-06 11:20 OysterDva New Issue
======================================================================
More information about the bugs
mailing list