You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Damir Vandic (damirv) said:
Any updates on this? (or a possible/recommended workaround)
For the interested reader: I encountered this issue with trying to use 'recursive existential types' to call the following Java method (Titan Graph database v0.5.0):
Related but perhaps slightly different: we hit this in our codebase during an upgrade of apache thrift due to TBase being typed in this way and scalac failing to infer a manifest for its erased type. The minimal repro in our case being:
repl_test ➤ echo "public interface Test<T extends Test<T>> {}" > Test.java
repl_test ➤ javac Test.java
repl_test ➤ scala -cp .
Welcome to Scala 2.13.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_161).
Type in expressions for evaluation. Or try :help.
scala> manifest[Test[_]]
java.lang.StackOverflowError
at scala.reflect.internal.Symbols$Symbol.isPrimaryConstructor(Symbols.scala:955)
at scala.tools.nsc.typechecker.Contexts$Context.withOuter$1(Contexts.scala:1123)
at scala.tools.nsc.typechecker.Contexts$Context.implicitssImpl(Contexts.scala:1146)
at scala.tools.nsc.typechecker.Contexts$Context.withOuter$1(Contexts.scala:1125)
...
That entry seems to have slain the compiler. Shall I replay
your session? I can re-run each line except the last one.
[y/n]
Interestingly, the same type can be inferred without issue if declared as a scala trait instead of the java interface.
Repro'ed with both java 8 & 11 on latest versions of 2.11, 2.12, and 2.13.
We did indeed switch to using a mix of tags (ClassTag where possible, TypeTag where required) which gets around this problem. I expect we'll have to revisit this when we eventually upgrade to Scala 3 as TypeTag seems to have been removed, but it's probably a few years yet before we cross that bridge.
Activity
scabug commentedon Aug 18, 2012
Imported From: https://issues.scala-lang.org/browse/SI-6255?orig=1
Reporter: Bruno Bieth (mustaghattack)
See #6528
scabug commentedon Jan 8, 2013
@retronym said:
It's not the same bug, but is in the same food group as #6528.
scabug commentedon Aug 15, 2014
Damir Vandic (damirv) said:
Any updates on this? (or a possible/recommended workaround)
For the interested reader: I encountered this issue with trying to use 'recursive existential types' to call the following Java method (Titan Graph database v0.5.0):
with TitanGraphQuery being
Example Scala code (without explicit types):
Does this bug mean I cannot use this method in Scala?
jvandew commentedon Sep 8, 2022
Related but perhaps slightly different: we hit this in our codebase during an upgrade of apache thrift due to TBase being typed in this way and scalac failing to infer a manifest for its erased type. The minimal repro in our case being:
Interestingly, the same type can be inferred without issue if declared as a scala trait instead of the java interface.
Repro'ed with both java 8 & 11 on latest versions of 2.11, 2.12, and 2.13.
SethTisue commentedon Sep 8, 2022
Consider using
ClassTag
if you don't need full type information, andTypeTag
if you do. As theManifest
documentation states:jvandew commentedon Sep 9, 2022
We did indeed switch to using a mix of tags (
ClassTag
where possible,TypeTag
where required) which gets around this problem. I expect we'll have to revisit this when we eventually upgrade to Scala 3 asTypeTag
seems to have been removed, but it's probably a few years yet before we cross that bridge.