Skip to content

Fix connectToPreferredDevice parameter type to resolve compilation error#1590

Merged
garthvh merged 2 commits into2.7.8from
copilot/sub-pr-1589
Feb 12, 2026
Merged

Fix connectToPreferredDevice parameter type to resolve compilation error#1590
garthvh merged 2 commits into2.7.8from
copilot/sub-pr-1589

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

What changed?

Changed connectToPreferredDevice function signature from device: Device to device: Device? = nil in AccessoryManager.swift.

Why did it change?

The function used nil-coalescing operator (device ?? fallback) on a non-optional parameter, which fails to compile. Making the parameter optional with a default value:

  • Enables the nil-coalescing logic to work correctly
  • Allows calling without arguments to auto-connect to preferred device
  • Maintains backward compatibility with existing call sites
// Before (compilation error)
func connectToPreferredDevice(device: Device) {
    let preferredDevice = device ?? self.devices.first(...) // ❌ Won't compile
}

// After (compiles correctly)
func connectToPreferredDevice(device: Device? = nil) {
    let preferredDevice = device ?? self.devices.first(...) // ✅ Works
}

How is this tested?

Existing call sites in AccessoryManager+Discovery.swift continue to work unchanged. Function can now also be called with no arguments.

Screenshots/Videos (when applicable)

N/A - Internal API change with no UI impact.

Checklist

  • My code adheres to the project's coding and style guidelines.
  • I have conducted a self-review of my code.
  • I have commented my code, particularly in complex areas.
  • I have verified whether these changes require an update to existing documentation or if new documentation is needed, and created an issue in the docs repo if applicable.
  • I have tested the change to ensure that it works as intended.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

…meter

Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on pull request 2.7.8 Fix connectToPreferredDevice parameter type to resolve compilation error Feb 12, 2026
Copilot AI requested a review from garthvh February 12, 2026 00:00
@garthvh garthvh marked this pull request as ready for review February 12, 2026 00:04
@garthvh garthvh merged commit 9f250e7 into 2.7.8 Feb 12, 2026
1 of 2 checks passed
@garthvh garthvh deleted the copilot/sub-pr-1589 branch February 12, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants