When I debug, I see that the inner class here gets a reference to its outer class, even though it's not using any values from the outer class. The only reason the inner class is an inner class is so it can reference the types of the outer class.
trait CorrectingParserWriter extends OptimizingParserWriter with EditorParserWriter {
...
final class SRCons[+Result](val head: LazyParseResult[Result], _tail: => SortedParseResults[Result]) extends SortedParseResults[Result] {
...
}
...
}
I added final
in an attempt to remove the reference to outer, but with no success.
To reduce memory consumption, I don't want the small object SRCons to have a reference to its outer class. However, de-nesting this inner class introduces many type parameters, which makes the code a mess.