participate


Java Compiler - incompatible, unrelated return types compile error
<<   Back to Forum  |   Give us Feedback
This topic has 2 replies on 1 page.
GarretWilson
Posts:195
Registered: 10/24/99
incompatible, unrelated return types compile error   
Nov 29, 2005 9:07 AM

 
I have:

public interface ActionControl<C extends ActionControl<C>> extends Control<C>
{
	public ActionModel getModel();
}
 
public interface ValueControl<V, C extends ValueControl<V, C>> extends Control<C>
{
	public ValueModel<V> getModel();
}
 
public interface ActionValueControl<V, C extends ActionValueControl<V, C>> extends ActionControl<C>, ValueControl<V, C>
{
	public ActionValueModel<V> getModel();
}
 
public interface ActionValueModel<V> extends ValueModel<V>, ActionModel
{
}


The 1.5_04 compiler gives me:

"ActionValueControl.java:9: types ValueControl<V,C> and ActionControl<C> are incompatible; both define getModel(), but with unrelated return types
public interface ActionValueControl<V, C extends ActionValueControl<V, C>> extends ActionControl<C>, ValueControl<V, C>"

The getModel() return types may be unrelated in the super interfaces, but the interface being defined clearly returns a type that satisfies both constraints.

This works just fine in Eclipse 3.1M2. How can I get this to work with javac?

Garret
 
GarretWilson
Posts:195
Registered: 10/24/99
Re: incompatible, unrelated return types compile error   
Jan 23, 2006 10:54 AM (reply 1 of 2)  (In reply to original post )

 
It turns out that this is a bug. Sun never replied to my bug submission almost two months ago (internal review ID 593682), but from Eclipse compiler bug discussions it appears that the Sun compiler does not comply with JLS3 9.4.1.

See:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=122881
https://bugs.eclipse.org/bugs/show_bug.cgi?id=122617

Garret
 
leptogenesis
Posts:39
Registered: 4/17/05
Re: incompatible, unrelated return types compile error   
Jun 23, 2008 6:21 PM (reply 2 of 2)  (In reply to original post )

 
Sorry for necroposting but...I'm having problems with this exact error in java 6. Is there any way to get code like this to compile? Perhaps using a different java compiler?

Edited by: leptogenesis on Jun 23, 2008 6:20 PM
 
This topic has 2 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 26
  • Guests : 129

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums