Note that there are some explanatory texts on larger screens.

plurals
  1. POExtending Java Class with Scala Trait
    primarykey
    data
    text
    <p>I would like to define a class <code>ContextItem</code> as the extension of java class <code>Predicate</code> with a trait <code>Confidence</code>.</p> <p>Confidence is a simple trait which simply adds a confidence field to whatever it extends.</p> <pre><code>trait Confidence{ def confidence:Double } </code></pre> <p>I am defining my <code>ContextItem</code> class by simply stating:</p> <pre><code>class ContextItem extends Predicate with Confidence{} </code></pre> <p>But attempting to compile this yields...</p> <pre><code>com/slug/berds/Berds.scala:11: error: overloaded method constructor Predicate with alternatives: (java.lang.String,&lt;repeated...&gt;[java.lang.String])com.Predicate &lt;and&gt; (java.lang.String,&lt;repeated...&gt;[com.Symbol])com.Predicate &lt;and&gt; (java.lang.String,java.util.ArrayList[com.Symbol])com.Predicate &lt;and&gt; (com.Predicate)com.Predicate &lt;and&gt; (com.Term)com.Predicate &lt;and&gt; (java.lang.String)com.Predicate cannot be applied to () class ContextItem(pred:Predicate) extends Predicate with Confidence{ ^ </code></pre> <p>This seems like a trivial example, so what's going wrong?</p> <p>Predicate (which is not mine) looks like:</p> <pre><code>/** Representation of predicate logical form. */ public class Predicate extends Term implements Serializable { public Predicate(String n) { super(n); } public Predicate(Term t) { super(t); } public Predicate(Predicate p) { super((Term)p); } public Predicate(String n, ArrayList&lt;Symbol&gt; a) { super(n, a); } public Predicate(String n, Symbol... a) { super(n, a); } public Predicate(String n, String... a) { super(n, a); } @Override public Predicate copy() { return new Predicate(this); } } </code></pre> <p>Neither Predicate nor any of its ancestors implements confidence.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload