Skip to content
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

Keep correct kind when preparing constraint in stripParams #14761

Merged
merged 2 commits into from Mar 24, 2022

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 23, 2022

Fixes #14760

@@ -248,7 +248,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
NoType
case tp: TypeBounds =>
val lo1 = stripParams(tp.lo, todos, !isUpper).orElse(defn.NothingType)
val hi1 = stripParams(tp.hi, todos, isUpper).orElse(defn.AnyKindType)
val hi1 = stripParams(tp.hi, todos, isUpper).orElse(tp.kind)
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to use TypeApplications#topType instead which I needed for the same reason :).

Suggested change
val hi1 = stripParams(tp.hi, todos, isUpper).orElse(tp.kind)
val hi1 = stripParams(tp.hi, todos, isUpper).orElse(tp.topType)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks! I had not remembered that.

topType already does what we need here, and it is also correct
for classes.
Copy link
Contributor

@Linyxus Linyxus left a comment

Choose a reason for hiding this comment

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

Thanks for checking the issue. LGTM!

@@ -229,7 +229,11 @@ class TypeApplications(val self: Type) extends AnyVal {
(alias ne self) && alias.hasSimpleKind
}

/** The top type with the same kind as `self`. */
/** The top type with the same kind as `self`. This is largest type capturing
* the parameter shape of a type without looking at precise bounds.
Copy link
Member

Choose a reason for hiding this comment

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

In fact, topType does keep around precise bounds (e.g., [X <: Int] =>> Any), though it could be tweaked to map the bounds themselves to topType if needed.

@odersky odersky merged commit 54dc0c1 into scala:main Mar 24, 2022
@odersky odersky deleted the fix-14760 branch March 24, 2022 08:06
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
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.

Unexpected error message when typing wildcard parameters in pattern
4 participants