Skip to content

Try to widen named types during box adaptation #23206

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Linyxus
Copy link
Contributor

@Linyxus Linyxus commented May 20, 2025

fixes #19076

@noti0na1 noti0na1 requested a review from Copilot May 22, 2025 12:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses issue #19076 by improving type adaptation during box adaptation by widening named types.

  • Adds a test case in the captures suite to validate impure capture checking.
  • Modifies the CheckCaptures component to introduce a widening strategy for named types and a fallback check using the widened type.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/pos-custom-args/captures/cc-tvar-impure.scala Adds a test scenario to assess correct type capture handling.
compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala Implements widening of named types with helper functions and fallback logic during box adaptation.
Comments suppressed due to low confidence (1)

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala:1338

  • [nitpick] Consider renaming 'tryThisType' to 'isInitiallyCompatible' to more clearly convey that the function checks the initial compatibility before attempting widening.
def tryThisType: Boolean =

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.

Under CC, subtyping between a type variable and its impure upper bound is rejected
1 participant