Research: Warning when type inference may fail after formatter removes explicit type
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 43
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Problem
Formatters (like SwiftFormat) often simplify patterns like:
let foo: Foo = Foo()
to:
let foo = Foo()
This is problematic for Implicits when the tool cannot infer the type from Foo() because it can't build a symbol registry for certain modules:
- Third party closed source (only
.swiftmodule, no source) - Objective-C modules
- Native OS libraries (UIKit, SwiftUI, Foundation, etc.)
Proposed Solution
Add a warning when an @Implicit variable has an explicit type annotation that might be removed by formatter. Suggest using the type parameter syntax:
@Implicit(Foo.self) var foo = Foo()
This preserves type information in a way formatters won't remove.
Research Needed
- Determine if
@Implicit(Type.self)syntax is currently supported - Consider if this should be a warning or just documentation guidance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin by checking whether the existing @Implicit(Type.self) syntax is supported. Review how explicit type annotations are handled and how formatter changes affect inference, then decide whether the appropriate outcome is a warning or documentation guidance. Done means documenting the finding and a clear recommendation for preserving type information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100