-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
Resolved Types lost when using xcodeproj integration instead of sources #887
Comments
@krzysztofzablocki @ilyapuchka Hey guys, would you mind paying attention to that issue, please? I've also faced that issue when I've tried to migrate from 0.18.0 to 1.0.0. I have a Prism template for my models with nested structure, like: struct Model: Equatable {
let kind: Kind; enum Kind: Equatable, AutoPrism {
case one, two
}
} And I expect to have generated prisms as: extension Model.Kind {
var isOne: Bool { ... }
var isTwo: Bool { ... }
} Instead, I'm getting a compile error, because the generated code now creates an extension with only extension Kind { // Error: No such type 'Kind'
var isOne: Bool { ... }
var isTwo: Bool { ... }
} Could you please tell me where I can find an appropriate spec to create a test case that will reproduce that issue? |
@RomanTysiachnik somewhere along ComposerSpec.swift:L1121 |
@samadhiBot I've added a spec that I think reproduces your setup and your changes fix it, do you mind providing an example of what you meant about those changes breaking other functionality? |
@krzysztofzablocki I'm still working on an example to illustrate the breaking changes with Generics. Will do my best to get it to you this week. |
@krzysztofzablocki I've pushed up at sample project to https://github.com/samadhiBot/sourcery-sample. It adds a custom generic type the example I used above, and I believe this should cover the remaining problems I alluded to earlier. The problem I was running into while trying to solve type lookup for generic types was that I could fix the If I remember correctly, having extensions on built-in types like Thank you again for looking into this, and let me know if I can try to clarify anything further. |
@samadhiBot thanks, I added test case for that scenario and I also run my current version against the sample and I get the expected results |
* chore(deps): bump redcarpet from 3.5.0 to 3.5.1 Bumps [redcarpet](https://github.com/vmg/redcarpet) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/vmg/redcarpet/releases) - [Changelog](https://github.com/vmg/redcarpet/blob/master/CHANGELOG.md) - [Commits](vmg/redcarpet@v3.5.0...v3.5.1) Signed-off-by: dependabot[bot] <support@github.com> * tests: add failing specs for modules issue #887 * refactor: apply samadhiBot changes * chore: update changelog Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
What version of Swift are you using (swift --version)?
Swift version: 5.3.1
What did you do?
Updated Sourcery from 0.18.0 to 1.0.2
What did you expect to see?
Actual types resolved as they were in 0.18.0
What did you see instead?
Certain actual types fail to resolve in 1.0.0 and later.
The issue appears to have been introduced in PR 834: Fixed namespace resolution for types. It does not seem to be a problem when specifying
sources
in the config.But when specifying
project -> target -> module
in the configuration, the keying change inComposer.uniqueTypesAndFunctions
fromunique[type.name]
tounique[type.globalName]
prevents laterType
lookups inComposer.actualTypeName
from resolving. In effect, the key contains the module name, but later lookups do not.The following demonstrates the issue.
Foo.swift:
Stats.stencil:
sample-sources.yml:
sample-targets.yml:
Output based on
sample-sources.yml
:Output based on
sample-targets.yml
:In the final sample, using Sourcery 1.0.2 and specifying a
project -> target -> module
configuration, the type for thebar
variable fails to resolve. It’s keyed in Sourcery’s unique types asFoo.Foo.Bar
(where the firstFoo
is the module), but subsequent attempts to resolve elements to the type are looking it up underFoo.Bar
.I’ve made some progress trying to resolve the issue, but once I got to generics types I started going in circles. Specifically, attempts to fix resolution of custom generic types along the lines of
Set<Foo>
would break resolution of other generics likeSet<Double>
, whenever we'd extended a built-in type (Double
in this example).The following changes cleaned up a big chunk of the problems in the generated code I’m working with, but this is an incomplete (and currently untested) solution.
The text was updated successfully, but these errors were encountered: