There is a public type exposed from a module with no hand-written public initializers. So the compiler ends up suggesting:
// In library modulepublicstructPageMetadata: Codable {
publicletpage: Intpublicletper: Intpubliclettotal: Int
}
// In client moduleletpm = PageMetadata(page: 1, per: 1, total: 1)
--
Extraargumentsatpositions #​1, #​2, #​3incallMissingargumentforparameter'from'incall
Looking at the source code for the library leads to confusion. Where did this 'from' parameter come from? And why can't I access the typical initializer? The library's code itself seems to be using {{PageMetadata.init(page:per:total) }}just fine, so what's the issue?
Both of these have reasonable answers, but that's not clear from the diagnostic. Instead, we should say something like (straw-man example):
I think this case should only trigger when all the public initializers of the type are synthesized.
In case we know that the initializer the user is trying to access is internal (I don't know if we serialize this information in swiftmodules/swiftinterfaces), we should say so (straw-man example):
typesanitizer commentedJul 1, 2020
Additional Detail from JIRA
md5: dd3ad03e817a4595803ce815de3025bd
Issue Description:
If you look at the forum thread: https://forums.swift.org/t/struct-initializer-in-extension/38063/4
There is a public type exposed from a module with no hand-written public initializers. So the compiler ends up suggesting:
Looking at the source code for the library leads to confusion. Where did this 'from' parameter come from? And why can't I access the typical initializer? The library's code itself seems to be using {{PageMetadata.init(page:per:total) }}just fine, so what's the issue?
Both of these have reasonable answers, but that's not clear from the diagnostic. Instead, we should say something like (straw-man example):
I think this case should only trigger when all the public initializers of the type are synthesized.
In case we know that the initializer the user is trying to access is internal (I don't know if we serialize this information in swiftmodules/swiftinterfaces), we should say so (straw-man example):
The text was updated successfully, but these errors were encountered: