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

Strange error on overriding generic Java method with Array parameter #5703

Closed
scabug opened this Issue Apr 24, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Apr 24, 2012

// Base.java
public abstract class Base<Params> {
	abstract void func(Params[] params);
}
//  Implementation.scala
class Implementation extends Base[Object] {
    override def func(params: Array[Object]) {}
}
error: class Implementation needs to be abstract, since method func in class Base of type (x$1: Array[Object with Object])Unit is not defined
(Note that Array[Params with Object] does not match Array[Object]: their type parameters differ)
class Implementation extends Base[Object] {

error: method func overrides nothing
override def func(params: Array[Object]) {}

Writingfunc(params: Array[Object with Object]) fixes problem, but how is Object with Object different from just Object?

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 24, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5703?orig=1
Reporter: Mikhail Trishchenkov (kriomant)
Affected Versions: 2.10.0-M2
See #4390

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 3, 2012

@adriaanm said:
the problem is that during override checking the types RefinedType(List(Object), EmptyScope) and TypeRef(.., Object, Nil) are seen as different, the refined type arises from the fix for 4390 (when scala&java are compiled together), or from the original restriction wrt generic arrays (see sigToType, RestrictJavaArraysMap)

I have a fix in the works for Object{} and Object being seen as different, but I feel like the Array[T] handling could be improved

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 3, 2012

@scabug scabug closed this May 4, 2012

@scabug scabug added the java interop label Apr 7, 2017

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017

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