Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix completion after application with implicit arguments
`List(1, 2, 3).map(f).<ctrl-space>` now works; before the tree had the type `(bf: CanBuildFrom[...]):...` and did not contribute completions from the result type. This commit checks if the tree has an implicit method type, and typechecks it as a qualifier. That is enough to get to `adaptToImplicitMethod` in the type checker, infer the implicit arguments, and compute the final result type accordingly.
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
reload: Completions.scala | ||
|
||
askTypeCompletion at Completions.scala(11,16) | ||
================================================================================ | ||
[response] aksTypeCompletion at (11,16) | ||
retrieved 24 members | ||
[accessible: true] `method !=(x$1: Any)Boolean` | ||
[accessible: true] `method !=(x$1: AnyRef)Boolean` | ||
[accessible: true] `method ##()Int` | ||
[accessible: true] `method ==(x$1: Any)Boolean` | ||
[accessible: true] `method ==(x$1: AnyRef)Boolean` | ||
[accessible: true] `method asInstanceOf[T0]=> T0` | ||
[accessible: true] `method eq(x$1: AnyRef)Boolean` | ||
[accessible: true] `method equals(x$1: Any)Boolean` | ||
[accessible: true] `method hashCode()Int` | ||
[accessible: true] `method isInstanceOf[T0]=> Boolean` | ||
[accessible: true] `method map(x: Int => Int)(implicit a: DummyImplicit)test.O.type` | ||
[accessible: true] `method ne(x$1: AnyRef)Boolean` | ||
[accessible: true] `method notify()Unit` | ||
[accessible: true] `method notifyAll()Unit` | ||
[accessible: true] `method synchronized[T0](x$1: T0)T0` | ||
[accessible: true] `method toString()String` | ||
[accessible: true] `method wait()Unit` | ||
[accessible: true] `method wait(x$1: Long)Unit` | ||
[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` | ||
[accessible: true] `value prefix123Int` | ||
[accessible: false] `method clone()Object` | ||
[accessible: false] `method finalize()Unit` | ||
================================================================================ |
3 changes: 3 additions & 0 deletions
3
test/files/presentation/completion-implicit-chained/Test.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import scala.tools.nsc.interactive.tests.InteractiveTest | ||
|
||
object Test extends InteractiveTest |
12 changes: 12 additions & 0 deletions
12
test/files/presentation/completion-implicit-chained/src/Completions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package test | ||
|
||
import scala.Predef.DummyImplicit // turn off other predef implicits for a cleaner .check file. | ||
|
||
object O { | ||
def map(x: Int => Int)(implicit a: DummyImplicit): O.type = this | ||
val prefix123 : Int = 0 | ||
} | ||
|
||
class Foo { | ||
O.map(x => x)./*!*/ // we want the presentation compiler to apply the implicit argument list. | ||
} |