Java interoperability with Scala using parameterized types

I'm experimenting with interoperability between Java and Scala and it looks like IDEA doesn't recognize Scala parameterized types when used from Java code. For example, if I have the following Java code:

public Tuple2<String,String> doStuff() {
// do stuff
}
 
public void test() {
  Tuple2<String,String> result = doStuff();
  String left = result._1;
}

I get an error marker on the line assigning _1 to the 'left' variable which complains that I can't assign Object to String. In other words, It's not recognizing the parameterized type.

Is this a known restriction of the Scala plugin or should it work?

IDEA 9.0.3, Scala plugin 0.3.1888.

Thanks,
Gordon

10 comments
Comment actions Permalink

More parameterized type oddness: If I have a Scala Object, which has a method that returns (String, String):

object Test {
  def doStuff(): (String, String) {
    return "stuff", "blah"
  }
}

And then I try to call that from Java:

public void testStuff() {
  Tuple<String,String> result = Test.doStuff()
  String left = result._1;
}

Then the call to Test.doStuff() is marked with a warning "unchecked assignment: 'scala.Tuple2<String,String> to 'scala.Tuple2<String,String>', which seems rather bogus.

Another known limitation or bug?

Thanks,
Gordon

0
Comment actions Permalink

> Another known limitation or bug?

It's a known issue, that's a work yet to be done.

0
Comment actions Permalink

Thanks Pavel.

Is there somewhere that lists the changes in each nightly build of the Scala plugin? I looked around the dev page for it but I couldn't find anything.

0
Comment actions Permalink

Now we haven't something like this. It's very bad (not to update change notes), and this practice will be restored (like it was year ago).

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

Thanks Alexander. I hope you'll get more people testing new builds once they know what has been changed. I know that uncertainty has made me hesitant to try new builds.

0
Comment actions Permalink

That just redirects to the jetbrains.com home page.

0
Comment actions Permalink

I am facing this issue even in the lastest version of IDEA. Is there a time horizon for when it might be fixed ?

0
Comment actions Permalink

I'm afraid, It won't be soon, because we have main work on Scala and Scala to Java interoperability (not Java to Scala).

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.