Skip to content

Runtime subtypte tests fail with illegal cyclic reference/inheritance exception #10312

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

Open
JanBessai opened this issue May 13, 2017 · 0 comments

Comments

@JanBessai
Copy link

Performing runtime subtype checks with <:< sometimes fails on Java classes.
With this code
I get:

$ javac Test.java
$ scalac RunTest.scala
$ scala RunTest
Test <:< Test:true
----------------------------------------------
Test <:< Bar:illegal cyclic reference involving type T
----------------------------------------------
Bar <:< Test:illegal cyclic inheritance involving class Test
----------------------------------------------
Bar <:< Bar:true
----------------------------------------------

I tested Scala versions 2.10.6, 2.11.8 and 2.12.2, which all have the same problem. I'm using Java version 1.8.0_112.

Note that turning the lambda function in Test.java into an anonymous inner class solves the issue. There is an article on InfoQ with details about the differences between lambdas and anonymous inner classes, which might be relevant.
The bug also disappears when using

class RefType<T extends RefType<?>> extends Base {}

instead of

class RefType<T extends RefType> extends Base {}

This might also be related to #3809 , but -Ybreak-cycles during compilation can and does not help here.

I ran into this bug, because of NodeWithThrownExceptions and MethodDeclaration in the current JavaParser release 3.2.3.

Here are full stacktraces for Test <: Bar and Bar <: Test.
Note that oddly getLocalizedMessage for Bar <: Test also seems to be different from the stacktrace without any try/catch block, while it is identical in the Test <: Bar case.

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

No branches or pull requests

1 participant