Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Instantiation of dependent expressions may not work

The getConstructors() method may have to do template instantiation in order to return constructors. Template instantiation requires a point of instantiation. Failure to provide the 'point' argument may cause the method to return incomplete or invalid results.

-sergey

On Mon, Feb 2, 2015 at 4:41 AM, Simon Levermann <simon@xxxxxxxxxxxxx> wrote:
Hi,

I'm currently in the process of developing an 'Encapsulate Field'
refactoring for the CDT, and I've run into a bit of a problem that I
don't quite understand:

In order to generate getters and setters that actually compile, I have
to find out whether the field I'm encapsulating is copyable
(forwarding/move setters might need to be generated instead of a
"regular" setter). In order to achieve this, I have written the
following class:
https://github.com/sonOfRa/cdt/blob/encapsulate_field/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/encapsulatefield/CopyabilityResolver.java

This class seems to operate correctly, however for some template types
inside the standard library, like std::unique_ptr<T>, an Exception with
the following message is logged: "Unsafe method call. Instantiation of
dependent expressions may not work.", from
org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPClassSpecialization.getConstructors(PDOMCPPClassSpecialization.java:276).

It then proceeds to invoke getConstructors() with point = null. The
documentation on when this can be "unsafe" is quite sparse (or I haven't
found the right piece of documentation yet). What exactly are the
implications of calling getConstructors() (or similar methods) with a
starting point that is null, and why is this method call unsafe? The
interface does not state any thrown Exceptions, which is why I'm
wondering how this case should be correctly handled.

Best regards,
Simon Levermann




_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top