digitalmars.D.bugs - [Issue 9249] New: Defining opCast disables Upcasting
- d-bugmail puremagic.com (33/33) Jan 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9249
- d-bugmail puremagic.com (27/27) Jan 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9249
- d-bugmail puremagic.com (12/12) Jan 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9249
- d-bugmail puremagic.com (9/9) Jan 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9249
http://d.puremagic.com/issues/show_bug.cgi?id=9249 Summary: Defining opCast disables Upcasting Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: blocker Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: puneet coverify.org --- This becomes blocking now since opCast is required for implementing toImpl. test.d(13): Error: template instance opCast!(Foo) does not match template declaration opCast(T) if (is(T == string)) class Bar { // 1 public T opCast(T)() // 2 if(is(T == string)) // 3 { // 4 return "Bar"; // 5 } // 6 } // 7 // 8 class Foo: Bar { } // 9 // 10 void main() { // 11 Bar bar = new Foo(); // 12 Foo foo = cast(Foo) bar; // 13 } // 14 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9249 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 20:40:57 PST --- What your sample is showing is downcasting, this is upcasting: class C1 { public T opCast(T)() if (is(T == string)) { return "C1"; } } class C2 : C1 { } void main() { C2 c2; C1 c1 = cast(C1)c2; } Both fail though. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9249 Puneet Goel <puneet coverify.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Defining opCast disables |Defining opCast disables |Upcasting |downcasting and explicit | |upcasting --- Yup, my bad. I have updated the summary as per Andrej's comment. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9249 20:58:23 PST --- I've tried a version as old as 2.032 which has the same behavior. It's odd this wasn't picked up before. What I think should happen is opCast should be tried first, and if it can't be instantiated try to do the regular upcast/downcast. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 10 2013