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

reflective compilation fails when instantiating classes using Java generic raw types #9328

Open
scabug opened this issue May 26, 2015 · 2 comments

Comments

@scabug
Copy link

scabug commented May 26, 2015

The reflective compiler seems unable to instantiate Java generic classes that use raw types for F-bounded polymorphism.
As shown in minimal test (attached), we can instantiate instances of GoodPoint from the reflective compiler:

public class GoodBase<SelfT extends GoodBase<?,?>, ElemT> {
 /* ... */
}
public class GoodPoint extends GoodBase<GoodPoint,Double> {
 /* ... */
}

But we get a CyclicReference exception from the reflective compiler if we try to instantiate BadPoint:

public class BadBase<SelfT extends BadBase, ElemT> {
 /* ... */
}
public class BadPoint extends BadBase<BadPoint,Double> {
 /* ... */
}

The Scala code snippet we are testing is:

 import actest.BadPoint
 val spt = new BadPoint(10)
 val s = spt.toString
 println("directCallTest: spt.toString ==> " + s)

The only difference between GoodPoint and BadPoint is the use of wilcard template parameters in the recursive template in GoodBase vs the raw type in the corresponding position in BadBase.
The above code snippet works fine if compiled directly but throws when used with the reflective compiler. The same code snippet using GoodPoint does not exhibit this issue.

@scabug
Copy link
Author

scabug commented May 26, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9328?orig=1
Reporter: Antony Courtney (antonycourtney)
Affected Versions: 2.11.6
Attachments:

@scabug
Copy link
Author

scabug commented Oct 2, 2015

Antony Courtney (antonycourtney) said:
Could someone from typesafe or EPFL please try the minimal test case provided in this issue and at least confirm that it is a bug? Any suggestions for a workaround would be very much appreciated.

Thanks

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