outfoxx / swiftpoet

Kotlin and Java API for generating .swift source files.
Apache License 2.0
277 stars 26 forks source link

Inferred type names are not finding "Swift." (amongst other things). #81

Closed lickel closed 6 months ago

lickel commented 1 year ago

Updating Square/Wire from v1.3.1 => v1.5, I saw a regression where declared type names are regularly being expressed with their fully qualified name.

We're semi-frequently doing something to the effect of io.outfoxx.swiftpoet.STRING.makeOptional().makeNotOptional(); however, we're also directly DeclaredTypeName.typeName("Wire.ProtoWriter") in an extension, which similarly loses the understanding of Wire being imported.

It looks like only types used within an extension have this limitation?

https://github.com/square/wire/pull/2454

lickel commented 1 year ago

Possibly related: if I use a DeclaredTypeName only in an extension, it doesn't implicitly import the module, which is kind of unexpected.

Related: https://github.com/square/wire/pull/2455/files#r1188014149

kdubb commented 1 year ago

@lickel Can you provide a repro case?

lickel commented 1 year ago

Certainly not all inclusive, but you'll notice the type public enum CodingKeys : Swift.String, Swift.CodingKey

SwiftPoet-Sample.zip

lickel commented 1 year ago

Sorry if that gradle config is not portable.

The output file is: SwiftPoet-Sample/app/SwiftPoet-Sample.swift

dnkoutso commented 6 months ago

I think this is caused by this https://github.com/outfoxx/swiftpoet/pull/55 change.

dnkoutso commented 6 months ago

I think this is actually resolved with https://github.com/outfoxx/swiftpoet/pull/90

kdubb commented 6 months ago

@dnkoutso Can you confirm this is fixed?

dnkoutso commented 6 months ago

I believe it is. Will close for now.