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

Swift: generating multiple output files can result in `Invalid redeclaration` errors #1166

Closed
lobianco opened this Issue Feb 6, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@lobianco
Copy link
Contributor

lobianco commented Feb 6, 2019

Because of Swift's default lenient access policy for functions we're noticing a few errors when generating multiple output files from our schema:

../Models/AddUserAccountRequest.swift:68:6: error: invalid redeclaration of 'newJSONDecoder()'
func newJSONDecoder() -> JSONDecoder {
     ^

../Models/AddUserAccountRequest.swift:76:6: error: invalid redeclaration of 'newJSONEncoder()'
func newJSONEncoder() -> JSONEncoder {
     ^

because these functions are duplicated in each file.

An appropriate solution might be to prepend the encoder/decoder function signatures with fileprivate which will restrict their exposure to their defining source files.

I'd be happy to put up a PR if this sounds reasonable!

@lobianco lobianco changed the title Swift: generating multiple output files can result in `Invalid redeclaration of 'newJSONDecoder()'` Swift: generating multiple output files can result in `Invalid redeclaration` errors Feb 6, 2019

@schani schani closed this in 9029a2c Feb 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment