Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java generic array cannot be used with Scala value types #5783

Open
scabug opened this issue May 10, 2012 · 3 comments
Open

Java generic array cannot be used with Scala value types #5783

scabug opened this issue May 10, 2012 · 3 comments

Comments

@scabug
Copy link

scabug commented May 10, 2012

This should produce a better error message.

Java file:

public class Test<T> {
  public T[] values;
}

Scala file:

class T {
  def foo() {
    val t = new Test[Int]
    val arr: Array[Int] = Array(1,2)
    t.values = arr
  }
}

scalac barks (when compiling together, or the Java file first):

T.scala:8: error: type mismatch;
 found   : Array[Int]
 required: Array[Int]
Note: Int >: Int, but class Array is invariant in type T.
You may wish to investigate a wildcard type such as `_ >: Int`. (SLS 3.2.10)
    t.values = arr
               ^
one error found
@scabug
Copy link
Author

scabug commented May 10, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5783?orig=1
Reporter: @lrytz
See #750

@scabug
Copy link
Author

scabug commented May 10, 2012

@retronym said:
See: scala/scala#479

I think the bug here is just the 'found: X, required: X` error message.

@scabug
Copy link
Author

scabug commented May 20, 2013

@JamesIry said:
2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant