[Issue 9249] New: Defining opCast disables Upcasting

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 1 08:20:44 PST 2013


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 at puremagic.com
        ReportedBy: puneet at coverify.org


--- Comment #0 from Puneet Goel <puneet at coverify.org> 2013-01-01 08:20:42 PST ---
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: -------


More information about the Digitalmars-d-bugs mailing list