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

Fix #10867: Normalize after applyIfParameterized in superType #13253

Merged
merged 3 commits into from
Sep 22, 2021

Conversation

OlivierBlanvillain
Copy link
Contributor

No description provided.

@OlivierBlanvillain OlivierBlanvillain marked this pull request as draft August 4, 2021 15:34
@OlivierBlanvillain OlivierBlanvillain marked this pull request as ready for review August 5, 2021 06:39
@@ -4110,7 +4110,7 @@ object Types {
cachedSuper = tycon match {
case tycon: HKTypeLambda => defn.AnyType
case tycon: TypeRef if tycon.symbol.isClass => tycon
case tycon: TypeProxy => tycon.superType.applyIfParameterized(args)
case tycon: TypeProxy => tycon.superType.applyIfParameterized(args).normalized
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure whether the caching is permissible here. If we normalize, are we certain that the next time around when we demand the super type of an applied type, we get the same normalization result? It does not look obvious to me.
Maybe we should do this instead.

    override def superType(using Context): Type =
      if ctx.period != validSuper then
        validSuper = if (tycon.isProvisional) Nowhere else ctx.period
        def reappliedSuper = tycon.superType.applyIfParameterized(args).normalized
        cachedSuper = tycon match
          case tycon: HKTypeLambda => defn.AnyType
          case tycon: TypeRef =>
            if tycon.symbol.isClass then tycon
            else
              if tycon.info.isInstanceof[MatchAlias] then validSuper = Nowhere
              reappliedSuper
          case tycon: TypeProxy => reappliedSuper
          case _ => defn.AnyType
      cachedSuper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR to change validity of the cache for normalizing match types.

@odersky
Copy link
Contributor

odersky commented Sep 22, 2021

LGTM

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