Scala Programming Language
  1. Scala Programming Language
  2. SI-6457

ImmutableSetFactory.empty results in StackOverflowError

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1, Scala 2.10.0-M7
    • Fix Version/s: Scala 2.11.0-M8
    • Component/s: Collections
    • Labels:

      Description

      scala> object Factory extends generic.ImmutableSetFactory[immutable.Set] {}
      defined module Factory
      
      scala> Factory.empty
      java.lang.StackOverflowError
      	at scala.collection.generic.ImmutableSetFactory.newBuilder(ImmutableSetFactory.scala:18)
      	at scala.collection.generic.GenericCompanion.empty(GenericCompanion.scala:37)
      	at scala.collection.generic.ImmutableSetFactory.newBuilder(ImmutableSetFactory.scala:18)
      	at scala.collection.generic.GenericCompanion.empty(GenericCompanion.scala:37)
      ...
      

      Not a regression, I saw the same thing in 2.9.1.

        Activity

        Hide
        Rex Kerr added a comment -

        Looking now.

        Show
        Rex Kerr added a comment - Looking now.
        Hide
        Rex Kerr added a comment -

        Everyone who implements it successfully actually overrides empty. So I propose we just remove the definition of empty and leave it abstract. Although it is formally possible to define the empty set inside the builder, in practice that's normally awkward. I'll submit a PR if we wish. Ideally you'd deprecate the non-abstractness to give people a chance to change, but I don't think we have that annotation? (It's the lesser-known cousin of deprecatedOverriding.)

        Show
        Rex Kerr added a comment - Everyone who implements it successfully actually overrides empty. So I propose we just remove the definition of empty and leave it abstract. Although it is formally possible to define the empty set inside the builder, in practice that's normally awkward. I'll submit a PR if we wish. Ideally you'd deprecate the non-abstractness to give people a chance to change, but I don't think we have that annotation? (It's the lesser-known cousin of deprecatedOverriding.)
        Hide
        Rex Kerr added a comment -

        Oh, I should add by "everyone" I mean "just the Scala library, but nobody in the giant bundle of jars that Adriaan got off of Maven inherited from ImmutableSetFactory, so it's just us that we have to worry about, probably".

        Show
        Rex Kerr added a comment - Oh, I should add by "everyone" I mean "just the Scala library, but nobody in the giant bundle of jars that Adriaan got off of Maven inherited from ImmutableSetFactory, so it's just us that we have to worry about, probably".
        Hide
        Adriaan Moors added a comment -

        The .001% of Scala users hit by this source incompatibility are likely to forgive us.

        Show
        Adriaan Moors added a comment - The .001% of Scala users hit by this source incompatibility are likely to forgive us.
        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/3366

          People

          • Assignee:
            Rex Kerr
            Reporter:
            Aleksandar Prokopec
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development