p-x9 / AssociatedObject

🔗 Swift Macro for allowing variable declarations even in class extensions
MIT License
126 stars 3 forks source link

Add Support for Basic Type Detection #20

Closed mlch911 closed 7 months ago

mlch911 commented 8 months ago

Add Support for Basic Type Detection.

You can now write code like this without type annotation.

@AssociatedObject(.OBJC_ASSOCIATION_ASSIGN)
var int = 10

@AssociatedObject(.OBJC_ASSOCIATION_ASSIGN)
var boolArray = [true, false]

@AssociatedObject(.OBJC_ASSOCIATION_ASSIGN)
var optionalIntArray = [1, 2, 3, nil]

@AssociatedObject(.OBJC_ASSOCIATION_ASSIGN)
var dic = ["t": "a", "s": "b"]
p-x9 commented 8 months ago

Thank you. I think it is a great idea and implementation.

I will read the code in more detail when I have more time.

p-x9 commented 7 months ago

@mlch911 I have read and tested the code and it was great.

One issue was related to the handling of arrays, as follows.

var doubleArray = [1, 2.0, 3.0]

In this case, there is a mix of Int and Double literals, but it should actually be treated as an array of Doubles.

The solution to this issue may be tedious, so if you want, I can continue to work on it.

mlch911 commented 7 months ago

@mlch911 I have read and tested the code and it was great.

One issue was related to the handling of arrays, as follows.

var doubleArray = [1, 2.0, 3.0]

In this case, there is a mix of Int and Double literals, but it should actually be treated as an array of Doubles.

The solution to this issue may be tedious, so if you want, I can continue to work on it.

Yes, please.

p-x9 commented 7 months ago

@mlch911

Hi, I have made some improvements based on your implementation. What do you think?

mlch911 commented 7 months ago

It's great. I think it's ready to merge.

p-x9 commented 7 months ago

Thank you very much. I will merge and release it.