digitalmars.D.bugs - [Issue 4088] New: opEquals not called on interfaces
- d-bugmail puremagic.com (36/36) Apr 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (7/7) May 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (11/11) Feb 13 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (11/11) Feb 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (10/12) Feb 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (18/18) Feb 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (10/10) Jun 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (10/10) Aug 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (14/14) Aug 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (14/22) Aug 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (14/20) Oct 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (6/6) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (21/21) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (14/14) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (14/14) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (9/9) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (12/12) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (16/16) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (12/12) Feb 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
- d-bugmail puremagic.com (10/10) Feb 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4088
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Summary: opEquals not called on interfaces Product: D Version: 2.041 Platform: Other OS/Version: All Status: NEW Severity: blocker Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: schveiguy yahoo.com 16:33:39 PDT --- Given an interface that defines opEquals, the compiler will prefer to call the object.opEquals(Object, Object) on it. However, interfaces don't implicitly cast to Objects thanks to COM. example: interface I { bool opEquals(I other); } bool foo(I i1, I i2) { return i1 == i2; } testopequals.d(8): Error: function object.opEquals (Object lhs, Object rhs) is not callable using argument types (I,I) testopequals.d(8): Error: cannot implicitly convert expression (i1) of type testopequals.I to object.Object testopequals.d(8): Error: cannot implicitly convert expression (i2) of type testopequals.I to object.Object And can someone add 2.042 and 2.043 to the version list? This is tested on 2.043. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4088 15:27:58 PDT --- Note, this is a problem for dcollections 2.0: http://www.dsource.org/projects/dcollections/ticket/4 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Created an attachment (id=907) Proposed fix It is actually a very surprising bug, that interfaces can't be compared as it might break structs due to the compiler generated opEquals. The attached patch does an explicit cast to Object. This would still not work with C++/COM interfaces. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 13 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Trass3r <mrmocool gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mrmocool gmx.de Can't dmd just check the "type" of a given interface and only allow implicit casts to Object if it is a normal one, i.e. no COM and no C++ interface? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 08:33:19 PST ---Can't dmd just check the "type" of a given interface and only allow implicit casts to Object if it is a normal one, i.e. no COM and no C++ interface?I'm not familiar with the internals of the compiler, but I believe this is true. I think it should be statically verifiable that an interface is a COM interface, and then opEquals can be handled differently. However, we continue to get silence from Walter on this... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Trass3r <mrmocool gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid I think this should be tackled at a deeper level, probably somewhere around MATCH TypeClass::implicitConvTo(Type *to) in mtype.c to allow implicit conversions of interfaces to Object in general. Then also this works: void foo(Object o) {} Interface i; foo(i); // or Object o = i; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |benoit tionex.de *** Issue 2794 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 10 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla digitalmars.com 16:25:25 PDT --- I'm not at all sure the patch is the right solution to this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 05 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 20:34:51 PDT --- Issues that need to be resolved: 1. what should happen if this is called with a COM object? 2. how does an opEquals defined in an interface interact with the object.opEquals? 3. a forced cast, unlike an implicit cast, is a blunt instrument that can do a lot more than simply cast an interface to its base class. If the arguments are other types, what are the conseqences of this forced cast? A change of this sort needs to resolve these issues, and have test cases to verify them. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 05 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 05:47:06 PDT ---Issues that need to be resolved: 1. what should happen if this is called with a COM object?Compiler error.2. how does an opEquals defined in an interface interact with the object.opEquals?If the notion of COM interfaces is specialized, then standard interfaces do not need to define opEquals, it's assumed that any standard interface (not C++ or COM) derives from Object, and implicit dynamic casting to Object to do opEquals should work.3. a forced cast, unlike an implicit cast, is a blunt instrument that can do a lot more than simply cast an interface to its base class. If the arguments are other types, what are the conseqences of this forced cast?An implicit cast to Object would be the best remedy. However, the issue of dynamic casting and blunt casting being conflated would be a good issue to solve too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 --- https://github.com/D-Programming-Language/druntime/pull/721. what should happen if this is called with a COM object?If two interfaces are identity comparable, returns its result. Otherwise, downcast to Object, and the result is false. And this rule also appleied to C++ interface (COM interface is C++ interface, and the downcasting from C++ interface to Object returns always null).2. how does an opEquals defined in an interface interact with the object.opEquals?An interface's opEquals is not used directly. Object.opEquals is always used for the interface comparison when it is possible.3. a forced cast, unlike an implicit cast, is a blunt instrument that can do a lot more than simply cast an interface to its base class. If the arguments are other types, what are the conseqences of this forced cast?-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 15 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4088 18:42:42 PST --- This is also the root cause of bug 7451. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 dawg dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dawg dawgfoto.de One point of it is to prefer interface opEquals over a downcast. Also, if an interface had an opEquals with a different signature, then Object.opEquals becomes hidden. interface IA { bool opEquals(IA o); } class A { bool opEquals(IA o) { return false; } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |code klickverbot.at 19:11:04 PST --- *** Issue 7451 has been marked as a duplicate of this issue. *** Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9c8b88ca89afef97a5d3b81ba7bd65cac71fd6d0 fix Issue 4088 - opEquals not called on interfaces -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |code klickverbot.at 19:11:04 PST --- *** Issue 7451 has been marked as a duplicate of this issue. *** Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9c8b88ca89afef97a5d3b81ba7bd65cac71fd6d0 fix Issue 4088 - opEquals not called on interfaces -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 dawg dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | Reopened because now implicit interface comparison is fixed, but having opEquals in interfaces still doesn't work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 20:16:23 PST --- Unless the checked-in fix doesn't allow two interfaces to compare, this bug should be closed. It is about the difference between comparing two objects and comparing two interfaces. Prior to this fix, you con't compare two interfaces *period*, even if they defined an identical signature to Object.opEquals. I feel that it should be possible to specialize opEquals for interfaces and objects, but this is a separate problem (and actually an enhancement). IIUC, the applied fix makes it so Objects and interfaces compare in the same way. If I find I can compare two interfaces in the same way I can compare two objects, I'll close this as resolved, and you may open a different bug regarding adding the enhancement of overriding the default behavior of object.opEquals. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID 22:36:28 PST --- If there's another issue, please open a new bug report, and please provide an example of the failing code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4088 Steven Schveighoffer <schveiguy yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |FIXED 05:36:21 PST --- Restoring resolution, this was fixed after all. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 09 2012