1

I have a java maven project which has dependency to scala project. I try to implement scala trait in java. The trait is store in packge object, when I try to implement it project fallen with compile time error Here sources:

scala source:

package com.compile.error

package object dummies {
    trait BaseDummy {
        def name: String
    }
    trait ChildDummy extends BaseDummy{

    }
}

java source:

//Uncoment for compile error
public class WhantImplementScalaTrait  /*implements com.compile.error.dummies.package$ChildDummy*/ {
}

So how implement scala trait as java interface if it in package object?

Full sources you can download here.

UPDATED

The command

javap package$ChildDummy.class

Gets result:

public interface com.compile.error.dummies.package$ChildDummy extends com.compile.error.dummies.package$BaseDummy {
}    

Tried imports

  • com.compile.error.dummies.package$.ChildDummy$Class
  • com.compile.error.dummies.package$.ChildDummy
  • com.compile.error.dummies.package$.MODULE$.ChildDummy$Class
  • com.compile.error.dummies.package$.MODULE$.ChildDummy
  • com.compile.error.dummies.package$ChildDummy
  • com.compile.error.dummies.package$ChildDummy$Class
3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.