Details

      Description

      Targeted type-checking in the presentation compiler is sometimes too precise. `askTypeAt(pos)` stops type-checking as soon as the smallest enclosing tree for `pos` has been typed. However, for overloaded method calls this is too early, since the type is not known before looking at the arguments.

      This happens for any overloaded method call.

      `askTypeAt` should be smarter, and continue type-checking if `tree.tpe.isOverloadedType`.

      Observable outcomes of this (in the IDE) are unknown 'hovers', broken hyperlinking that suddenly starts working, unresolved ScalaDoc comments.

        Activity

        Hide
        Eugene Vigdorchik added a comment -

        Checking for isOverloadedType looks less safe (why should the type-check continue, and what is the contract of askTypeAt if your fix is applied) than the IDE itself asking at the position of Apply. So why not fix it on the IDE side?

        Show
        Eugene Vigdorchik added a comment - Checking for isOverloadedType looks less safe (why should the type-check continue, and what is the contract of askTypeAt if your fix is applied) than the IDE itself asking at the position of Apply. So why not fix it on the IDE side?
        Hide
        Iulian Dragos added a comment -

        Hey Eugene!

        I think the contract is that "askTypeAt" should give you the same type whether the file was fully type-checked or "targeted" type-checked. Right now, if the file was fully type-checked the `Select` has the resolved symbol, while a targeted type-check gives back an overloaded type.

        Show
        Iulian Dragos added a comment - Hey Eugene! I think the contract is that "askTypeAt" should give you the same type whether the file was fully type-checked or "targeted" type-checked. Right now, if the file was fully type-checked the `Select` has the resolved symbol, while a targeted type-check gives back an overloaded type.
        Hide
        Eugene Vigdorchik added a comment -

        Hey Iulian,

        That's a great idea to formalize the contract! What you say is the type returned by targeted type-check (if any) is the same as the type obtained by full type-check, right?
        That would be great to have. However may it be that `tree.tpe.isOverloadedType` is not only true for method calls?
        Seems analyzing tree structure is safer than type-checking enclosing tree unconditionally?

        Show
        Eugene Vigdorchik added a comment - Hey Iulian, That's a great idea to formalize the contract! What you say is the type returned by targeted type-check (if any) is the same as the type obtained by full type-check, right? That would be great to have. However may it be that `tree.tpe.isOverloadedType` is not only true for method calls? Seems analyzing tree structure is safer than type-checking enclosing tree unconditionally?
        Hide
        Mirco Dotta added a comment -

        I'm looking into this.

        Show
        Mirco Dotta added a comment - I'm looking into this.
        Show
        Mirco Dotta added a comment - https://github.com/scala/scala/pull/3177
        Show
        François Garillot added a comment - https://github.com/scala/scala/pull/3208

          People

          • Assignee:
            Mirco Dotta
            Reporter:
            Iulian Dragos
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development