[GSoC 2025] Re-implement property wrappers with macros

Usually everything gets moved to new implementation as incrementally as possible and we'd remove only implementation once everything has been switched over.

1 Like

Thanks for your reply.

I came up with a small new language feature that could solve the problem I pointed out.

It’s a special macro called #inferredType.
This can be written as the type of a computed property.
The compiler would expand it using the result of type inference from the get accessor’s expression.

Example:

struct Foo {
  var value: #inferredType {
    get { 0 }	
  }
}

struct Foo_expand {
  var value: Int {
    get { 0 }	
  }
}

If this existed, it would resolve all of the examples I mentioned.

struct Pattern1_expand {
    var _w = Simple(wrappedValue: Ext.foo())

    var w: #inferredType {
        get { _w.wrappedValue }
        set { _w.wrappedValue = newValue }
    }
}

struct Pattern2_expand {
    var _w = InterLeft(wrappedValue: .foo())

    var w: #inferredType {
        get { _w.wrappedValue }
        set { _w.wrappedValue = newValue }
    }
}

struct Pattern3_expand {
    var _w = ProtocolInferLeft(wrappedValue: .value)

    var w: #inferredType {
        get { _w.wrappedValue }
        set { _w.wrappedValue = newValue }
    }
}

struct Pattern4_expand {
    var _w = MetaParameter(wrappedValue: .init(), MPValue())

    var w: #inferredType {
        get { _w.wrappedValue }
        set { _w.wrappedValue = newValue }
    }
}

All of the examples can be generated in a systematic way.
The key point is that the generated stored property’s type is exactly the same as the property wrapper’s type.
By fully writing out the initialization call, the type can then be resolved.

3 Likes

looks really good. this looks like the custom macros for edge cased that I have proposed while crating tests. Im sure when we do that we can use this for sure.

side note- i was about to submit my final draft of the proposal soon and i was wondering it you could just give it one last look.

thanks,
Arihant

1 Like

@ktoso I am happy to annouce that I have made my final submission of my propsal for the said project and hope you will be able to review it through formal Gsoc channels now.

1 Like

all understood sir , I have submitted my final proposal and will be waiting upon the acceptance to get the work started for this project. Hope I will be colaborating and making big changes in the proposed section while learning from you over the summer.

special thanks to @omochimetaru for helping me out and giving me some importnt pointers and ideas as well and hope to hear more from him as well.

1 Like

Dear Swift Community,

I wanted to express my sincere gratitude for the opportunity to participate in the Google Summer of Code application process with a proposal for the re-implementation of property wrappers. Although my proposal wasn't selected for this year's program, the experience has been incredibly valuable.

I am especially thankful to @xedin,@ktoso and @omochimetaru who generously offered their time, expertise, and guidance throughout the application process. Your feedback and support have significantly contributed to my growth as a developer and deepened my understanding of Swift.

To the broader Swift community, thank you for fostering such a collaborative and educational environment. The discussions, resources, and encouragement I've received over the past few months have been instrumental in shaping my proposal and enhancing my skills.

While I'm disappointed that I won't be working on this project as part of GSoC, I remain enthusiastic about contributing to Swift in other ways and hope to continue engaging with this exceptional community.

As I navigate my way through this experience, I expect to take this failure to convert this opportunity as just another reminder to constantly improve myself and keep coming up with ideas that can help me build something meaningful.

Thank you again for this enriching experience.

Sincerely,
Arihant Marwaha

6 Likes