Skip to content

Analysis: Point should not extend Kotlin Pair#34

Closed
Copilot wants to merge 3 commits intodevelopfrom
copilot/extend-pair-from-tuples
Closed

Analysis: Point should not extend Kotlin Pair#34
Copilot wants to merge 3 commits intodevelopfrom
copilot/extend-pair-from-tuples

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 10, 2026

Issue requests analysis whether Point class should extend/use Kotlin's Pair. Analysis concludes: no implementation recommended.

Decision: Keep Point Independent

Point is a domain-specific 2D coordinate type with geometric semantics. Kotlin's Pair is a generic tuple. Merging them would:

  • Lose semantic clarity: point.x/ypoint.first/second
  • Eliminate type safety: any Pair<Int, Int> becomes a valid Point
  • Break 129 usage sites + 18 tests
  • Require distance() as extension on all Pair<Int, Int> instances
  • Provide zero functional benefit

Comparison

// Current: clear domain semantics
val point = Point(10, 20)
val dist = point.distance(other)  // x, y are self-documenting

// With Pair: loses meaning
typealias Point = Pair<Int, Int>
val point = Point(10, 20)
point.first  // Which coordinate is this?

val screenSize = Pair(1920, 1080)  // Same type, different concept
point.distance(screenSize)  // Type system cannot prevent this

Precedent

Doubleton<T, V> was retained during Kotlin migration rather than replaced with Pair due to domain-specific semantics (unordered equality, associated values). Same principle applies.

Kotlin Ecosystem Alignment

Standard library favors domain types over generic tuples:

  • kotlin.time.Duration not Pair<Long, TimeUnit>
  • kotlin.ranges.IntRange not Pair<Int, Int>
  • androidx.compose.ui.geometry.Offset not Pair<Float, Float>

Documentation

  • POINT_PAIR_ANALYSIS.md: Technical analysis with code examples, type safety implications, impact assessment
  • IMPLEMENTATION_SUMMARY.md: Executive summary and resolution

No code changes. Current design is optimal.

Original prompt

This section details on the original issue you should resolve

<issue_title>Point to kotlin Pair</issue_title>
<issue_description>cz.vutbr.fit.interlockSim.util schould extends Pair from Tuples.kt.</issue_description>

<agent_instructions>analyse is good be and iplemement is possilbe</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 10, 2026 13:50
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Copilot AI changed the title [WIP] Extend cz.vutbr.fit.interlockSim.util with Pair from Tuples.kt Analysis: Point should not extend Kotlin Pair Jan 10, 2026
Copilot AI requested a review from bedaHovorka January 10, 2026 13:52
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Owner

@bedaHovorka bedaHovorka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for analyze, we can close this pr @copilot

@bedaHovorka
Copy link
Copy Markdown
Owner

impossible implementation

Copilot AI requested a review from bedaHovorka January 10, 2026 15:06
Copilot stopped work on behalf of bedaHovorka due to an error January 10, 2026 15:06
@bedaHovorka bedaHovorka deleted the copilot/extend-pair-from-tuples branch January 10, 2026 15:08
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.

Point to kotlin Pair

2 participants