-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
SwiftData class: Method does not override any method from its superclass #56
Comments
Are you sure you are able to reproduce this with this code snippet, for me this code snippet doesn't produce error. Can you provide a sample project for this?
Can you provide sample project for this, I can think of one scenario where this error would come: Note If you are manually conforming to Anyway I can't do much here with the screenshots, please provide a minimal reproducible sample. |
Here's a repo: https://github.com/ashleydw/metacodable-min-ex/blob/main/test/Item.swift If you build you should get the same error on Item.swift. Commenting out |
Thanks @ashleydw for providing sample, I can reproduce your issue. The issue doesn't seem to be combining https://github.com/ashleydw/metacodable-min-ex/blob/c0bd383995ca3c12938f704b79429e2c9c7b0c9b/test/ContentView.swift#L6 Seems like with these line present Swift is not providing protocol conformance data to |
Same issue here, problem magically disappear when |
@ashleydw @Willian-Zhang has any of you created discussion on Swift forum or Apple developer forum? I am afraid this issue is not related to |
I haven't, I wasn't able to identify where the problem lies to. |
Simple overview of the class implementation generation by
The strange thing here is without those lines the Swift compiler invokes the following flow:
and with those lines present the Swift compiler invokes the following flow:
which is a strange behaviour from compiler, as of why compiler provides wrong data in some cases, only Swift compiler team can answer. |
@soumyamahunt great insight! If not, do you think there is way to go around with this problem? I am very interested in this cross usage on SwiftData+MetaCodable, as it would vastly simplify my code in a project that I started recently. (Actually I'm current on a track giving up on |
@ashleydw @Willian-Zhang new macro |
having Inherits tested, I can confirm this solved my problem perfectly. |
not sure what i'm doing wrong. using the @Codable
@Model
@Inherits(decodable: false, encodable: false)
final class TestModel: Codable, Identifiable {
var id: Int = 0
var url: String = ""
var name: String = ""
init(id: Int, url: String, name: String) {
self.id = id
self.url = url
self.name = name
}
} Fails with EDIT: solved by removing the |
@rursache you have to remove the manual |
@soumyamahunt I can confirm it works in my project, thanks! |
Please, release a new version with this fix |
@bfalcinelli currently the proper fix can be done from compiler end, as the issue arises due to compiler providing wrong data to 'MetaCodable'. The current work around has been released: https://github.com/SwiftyLab/MetaCodable/releases/tag/v1.4.0 |
If a SwiftData model annotation is added to a class, the build will fail with "Method does not override any method from its superclass".
It can be reproduced using a clean SwiftData project, adding the SPM package from 1.2.1, and the following class:
Expanding the macro actually shows it doesn't add the
super.*
calls:I have however managed to produce one expansion with the error:
The text was updated successfully, but these errors were encountered: