Ticket #10 (new defect)

Opened 6 months ago

Last modified 6 months ago

Font constructor ambiguous

Reported by: nascent Assigned to: somebody
Priority: minor Milestone:
Component: component1 Version:
Keywords: Cc:

Description

In graphics/Font.d there are two constructors, on is a float tho there takes an int. This is ambiguous when you try to construct using an int. float version only?

Change History

03/06/08 03:44:58 changed by keinfarbton

I had this ambiguity also. My case was like

Display display = Display.getCurrent();
new Font( display, "Name", 2, DWT.NONE );

See: dwt-linux/dwt/custom/StyledText.d:471

The ambiguity results, because of there is a implicit cast necessary for display. Now the overloading rules for D become active and throw this error. Casting the display to Device made the ambiguity go away.

Display display = Display.getCurrent();
new Font( cast(Device) display, "Name", 2, DWT.NONE );

In the Java original the float version is declared like this:

/*public*/ Font(Device device, String name, float height, int style) {

In D, this ctor is still visible. Can you try your case with this ctor changed to "package" ?