Skip to content

Fix #8573: Fix higher-kinded bounded opaque types #8580

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

Merged
merged 1 commit into from
Mar 22, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 20, 2020

  • Fix the type parameters with which explicitly given bounds of a higher-kinded
    opaque type should be abstracted.

  • Explicitly disallow unapplied right-hand sides of opaque types. They will lead
    to bad bounds later anyway, so we should give an intelligible error message
    early on.

Open question: Should we disallow all unapplied right hand sides for all type aliases,
not just opaque ones?

 - Fix the type parameters with which explicitly given bounds of a higher-kinded
   opaque type should be abstracted.

 - Explicitly disallow unapplied right-hand sides of opaque types. They will lead
   to bad bounds later anyway, so we should give an intelligible error message
   early on.

Open question: Should we disallow all unapplied right hand sides for all type aliases,
not just opaque ones?
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -460,7 +462,7 @@ object SymDenotations {
info match
case TypeAlias(alias) if isOpaqueAlias && owner.isClass =>
setAlias(alias)
HKTypeLambda.boundsFromParams(alias.typeParams, bounds(rhs))
HKTypeLambda.boundsFromParams(tparams, bounds(rhs))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, we have to use tparams instead of alias.typeParams due to the following test in boundsFromParams?

      def isOpaqueAlias = params match
        case (param: Symbol) :: _ => param.owner.is(Opaque)
        case _ => false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alias.typeParams is a list of TypeParamRefs, which are different from the symbols on rhs. That caused the problem.

@odersky odersky merged commit 8d1a912 into scala:master Mar 22, 2020
@odersky odersky deleted the fix-#8573 branch March 22, 2020 10:22
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.

2 participants