[Issue 10971] assigning derived class to base should not trigger promotion of result

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 5 07:32:09 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10971



--- Comment #2 from monarchdodra at gmail.com 2013-09-05 07:32:08 PDT ---
(In reply to comment #1)
> I doubt it will ever be implemented because it breaks static typing of D. In
> second example type of a is "A" and not "B" and your request would require
> compiler to accept/reject sometimes arguments depending on context. For
> example, initializer for a can be not new B, but Object foo() and in such
> context compiler cannot know whether returned value is trully B or not.

Depends on how you see it I guess. I could that I see it that the initializer
is "new B", yet *because of context* (assign to "a" while we are at it), it
doesn't compile.

But I don't think this has anything to do with context. Just that "a = b" is an
operation, and like all operations, it has a return type. I think we could
improve what that type is. We could make it "The type A, but implicitly
cast-able to B"

That would be "nice to have".

-- 
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