Scala Override Return Type <p>I have a task in which I need to override the return type of a method. The problem is the method is called yet the return type is not overridden. Please help!</p> <pre><code>abstract class Parser { type T1 &lt;: Any; def test1(): T1; type T2 &lt;: String; def test2(): T2; } //class path: parser.ParserA class ParserA extends Parser { type T1 = String; override def test1(): T1= { return "a,b,c"; } type T2 = String; override def test2(): T2= { return "a,b,c"; } } //some where in the project val pa = Class.forName("parser.ParserA").newInstance().asInstanceOf[Parser]; println(pa.test1().length());// error: value length is not a member of pa.TYPE_4 println(pa.test2().length());// this works, print 5; </code></pre> <p>Please Help! Thank you in advance!</p>