2014-10-30 41 views
0

我写在Java和斯卡拉(使用互操作)一个程序,它不断给我这个编译错误至极没有意义....斯卡拉非法继承错误是没有意义的

说明资源路径位置类型 非法继承;继承不同类型的特征IEvaluationFunction实例:core.interfaces.IEvaluationFunction [core.representation.ILinearRepresentation [Double]]和core.interfaces.IEvaluationFunction [core.representation.ILinearRepresentation [Double]] IConstructors.scala/ScalaMixins - Parjecoliv1/src/aop第36行Scala问题

它说它继承不同类型的实例,但它们是相同的。他们都:

core.interfaces.IEvaluationFunction [core.representation.ILinearRepresentation [双]

有人可以帮我解决或理解这一点?

该代码:

这是它给出错误的地方。代码在Scala中。

def createFermentationEvaluation(fermentationProcess:FermProcess, 
    interpolationInterval:Int):FermentationEvaluation = { 
    return new FermentationEvaluation(fermentationProcess,interpolationInterval) 
    with EvaluationFunctionAspect[ILinearRepresentation[Double]] 
} 

这里是接口和类,它使用:

public class FermentationEvaluation 
    extends EvaluationFunction<ILinearRepresentation<Double>> 

trait EvaluationFunctionAspect[T <:IRepresentation] 
    extends IEvaluationFunction[T] {...} 

public abstract class EvaluationFunction<T extends IRepresentation> 
    implements IEvaluationFunction<T>,java.io.Serializable {...} 

public interface IRepresentation {...} 

public interface ILinearRepresentation<E> extends IRepresentation {...} 

我并没有包括任何的身体,因为它似乎是一个继承的问题。

+0

请用标志'-explaintypes'进行编译。 – 2014-10-30 04:54:30

回答

3

其中一种类型是java.lang.Double - 在Java中定义的一个,其中没有scala.Double,另一个是scala.Double - 在Scala中定义的一个。

这些是两种不同的类型。 scala.Double实际上是Java的基本原型double,并且当用作类型参数时,它将擦除到Object。它不能擦除到java.lang.Double,因为在某些条件下扩展类型时会中断。