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

Can't use default Seq in CorsSettings methods #48

Open
timglauert opened this issue Mar 9, 2019 · 1 comment
Open

Can't use default Seq in CorsSettings methods #48

timglauert opened this issue Mar 9, 2019 · 1 comment

Comments

@timglauert
Copy link

Some methods in CoreSettings take a Seq, e.g. CoreSettings.withAllowedMethods. However this does not work with the default Seq that is imported from the scala package. It requires the more restrictive scala.collection.immutable.Seq which is a subclass of the default Seq.

The reason for this is that CorsSettings.scala has import scala.collection.immutable.Seq so all uses of Seq refer to the more restrictive type. Looking at the code there appears to be no benefit from this more restrictive type, so the fix is to remove the import.

@lomigmegard
Copy link
Owner

You're right that we are using the immutable Seq collection in all our APIs. This is however a design choice, as we prefer enforcing strict immutability on such public APIs.

Usually the simplest way to get an immutable Seq instance is to construct a List directly or to convert your collection to one using .toList.

Note that it's also the direction Scala is taking, as collections in 2.13 (and Scala 3) will have the immutable Seq as the new default:

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