4

I have a method defined in Java like:

void foo(int x, Thing... things)

I need to override that in Scala, but both of these give errors:

override def foo(x: Int, things: Thing*)
override def foo(x: Int, things: Array[Thing])

The errors refer to <repeated...> but I don't know what that is.

Update

Ugg... nevermind. I'm in 2.10.0, and I had mis-typed something and didn't have a method body. Then I got confused by this error message, which still seems a odd to me. In SBT:

> compile
[info] Compiling 1 Scala source to [...]/target/scala-2.10/classes...
[error] [...]/src/main/scala/Translator.scala:41: class MyMethodVisitor needs to be abstract, since method visitTableSwitchInsn is not defined
[error] (Note that org.objectweb.asm.Label* does not match <repeated...>[org.objectweb.asm.Label])
[error]   class MyMethodVisitor extends MethodVisitor (Opcodes.ASM4) {
[error]         ^

The problem is that my visitTableSwitchInsn simply lacks a body, but the error suggests that the problem is the type of the varargs parameter.

2
  • 1
    This looks like you may be seeing a bug that was fixed in 2.10. If you think not, can you give your version number and a little more context? Commented Jan 15, 2013 at 23:29
  • Thanks. I was seeing a bug in my brain, plus a confusing error message (which I've added to the question). Commented Jan 16, 2013 at 1:38

1 Answer 1

1

Java:

package rrs.scribble;

public
class   VA1
{
    public int va1(int... ints) {
        return ints.length;
    }
}

Scala:

package rrs.scribble

class   VA1S
extends VA1
{
  override
  def va1(ints: Int*): Int =
    ints.length * 2
}

SBT:

> ~compile
[info] Compiling 1 Scala source and 1 Java source to …/scribble/target/scala-2.10/classes...
[success] Total time: 4 s, completed Jan 15, 2013 3:48:14 PM
1. Waiting for source changes... (press enter to interrupt)

This is Scala 2.10, which is consistent with @TravisBrown's comment.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. When I returned after a break, I saw my obvious code mistake. :| My method simply lacked a body. Maybe the error message could be better. I updated the question.

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.