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

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

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

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

scabug opened this issue Apr 24, 2012 · 3 comments
Assignees
Milestone

Comments

@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
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
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
Copy link
Author

scabug commented May 3, 2012

@adriaanm said:
fixed by adriaanm/scala@7a5aaa9

@scabug scabug closed this as completed May 4, 2012
@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
Projects
None yet
Development

No branches or pull requests

2 participants