# Scala cannot override the method whose parameter is raw type of a scala defined class

**URL:** <https://users.scala-lang.org/t/scala-cannot-override-the-method-whose-parameter-is-raw-type-of-a-scala-defined-class/6766>\
**Category:** Question\
**Created:** [October 22, 2020, 2:49pm UTC](https://users.scala-lang.org/t/scala-cannot-override-the-method-whose-parameter-is-raw-type-of-a-scala-defined-class/6766 "2020-10-22T14:49:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![puyvqi](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@puyvqi](https://users.scala-lang.org/u/puyvqi)\
**Post date:** [October 22, 2020, 2:49pm UTC](https://users.scala-lang.org/t/scala-cannot-override-the-method-whose-parameter-is-raw-type-of-a-scala-defined-class/6766/1 "2020-10-22T14:49:05Z")

</div>

for example,define a scala class :

> class scalaclass[T] {  
> val i: Array[T] = null  
> }

define a java interface whose method raw use this class :

> public interface cc {  
> public scalaclass apply();  
> }

finally, implement this interface in scala:

> class typetest extends cc {  
> override def apply(): scalaclass[\_] = {null}  
> }

then compiler report error :

> “overriding method apply in trait cc of type ()scalaclass;  
> method apply has incompatible type  
> override def apply(): scalaclass[\_] = {”

i tried scalaclass [\_], scalaclass[Any], scalaclass[AnyRef], scalaclass… all dont work.  
could someone help me?

---

<div class="post-metadata">

**Author:** ![sangamon](https://users.scala-lang.org/user_avatar/users.scala-lang.org/sangamon/32/68_2.png) [@sangamon](https://users.scala-lang.org/u/sangamon)\
**Post date:** [October 22, 2020, 3:39pm UTC](https://users.scala-lang.org/t/scala-cannot-override-the-method-whose-parameter-is-raw-type-of-a-scala-defined-class/6766/2 "2020-10-22T15:39:30Z")

</div>

I don’t think this is possible - there simply is no equivalent to the Java raw type on the Scala side. (And I think that’s a good thing.) Perhaps [this blog post](https://typelevel.org/blog/2015/02/26/rawtypes.html) can give you some inspiration to tackle things from a slightly different angle on the Java side.
