Skip to content

Instantly share code, notes, and snippets.

@JoshRosen
Created July 9, 2012 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshRosen/3079407 to your computer and use it in GitHub Desktop.
Save JoshRosen/3079407 to your computer and use it in GitHub Desktop.
Scala NoSuchMethodError when using traits from Java
public class JavaTest {
public static void main(String[] args) {
MyClass<Integer> x = new MyClass<Integer>();
x.hello();
x.myVal();
}
}
trait MyTrait[T, This <: MyTrait[T, This]] {
def x: This
def myVal(): This = x
def hello() = {System.out.println("HELLO")}
}
class MyClass[T]() extends MyTrait[T, MyClass[T]] {
def x : MyClass[T] = new MyClass
}
object ScalaTest {
def main(args: Array[String]) {
val x : MyClass[Int] = new MyClass[Int]
x.hello()
x.myVal()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment