Skip to content

Backport "Instantiate Type Vars in completion labels of extension methods" to LTS #20879

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 2 commits into from
Jul 1, 2024

Conversation

WojciechMazur
Copy link
Contributor

@WojciechMazur WojciechMazur commented Jun 28, 2024

Backports #18914 to the LTS branch.

PR submitted by the release tooling.

This PR fixes the completion labels for extension methods and old style
completion methods.

It required an API change of `Completion.scala` as it didn't contain
enough information to properly create labels on presentation compiler
side. Along with this following parts were rewritten to avoid
recomputation:
- computation of adjustedPath which is necessary for extension construct
completions,
- computation of prefix is now unified across the metals and
presentation compilers,
- completionKind was changed, and kind Scope, Member are now part of
completion mode.


The biggest change is basically added support for old style extension
methods.
I found out that the type var was not instantiated after
`ImplicitSearch` computation, and was only calculated at later stages. I
don't have enough knowledge about Inference and Typer to know whether
this is a bug or rather an intended behaviour but I managed to solve it
without touching the typer:
```scala

      def tryToInstantiateTypeVars(conversionTarget: SearchSuccess): Type =
        try
          val typingCtx = ctx.fresh
          inContext(typingCtx):
            val methodRefTree = ref(conversionTarget.ref, needLoad = false)
            val convertedTree = ctx.typer.typedAheadExpr(untpd.Apply(untpd.TypedSplice(methodRefTree), untpd.TypedSplice(qual) :: Nil))
            Inferencing.fullyDefinedType(convertedTree.tpe, "", pos)
        catch
          case error => conversionTarget.tree.tpe // fallback to not fully defined type
```
[Cherry-picked 95266f2]
Base automatically changed from lts-18889 to lts-3.3 July 1, 2024 08:40
@WojciechMazur
Copy link
Contributor Author

No regressions detected in the community build up to lts-19605.

Reference

@WojciechMazur WojciechMazur merged commit fd1560e into lts-3.3 Jul 1, 2024
19 checks passed
@WojciechMazur WojciechMazur deleted the lts-18914 branch July 1, 2024 08:40
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