From 6045a05b833c930dfaf343215ac645f4f32f3e2a Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 6 Nov 2013 14:58:01 +0100 Subject: Fix completion after application with implicit arguments `List(1, 2, 3).map(f).` 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. --- .../presentation/completion-implicit-chained.check | 29 ++++++++++++++++++++++ .../completion-implicit-chained/Test.scala | 3 +++ .../src/Completions.scala | 12 +++++++++ 3 files changed, 44 insertions(+) create mode 100644 test/files/presentation/completion-implicit-chained.check create mode 100644 test/files/presentation/completion-implicit-chained/Test.scala create mode 100644 test/files/presentation/completion-implicit-chained/src/Completions.scala (limited to 'test/files/presentation') diff --git a/test/files/presentation/completion-implicit-chained.check b/test/files/presentation/completion-implicit-chained.check new file mode 100644 index 0000000000..6d30a61cf9 --- /dev/null +++ b/test/files/presentation/completion-implicit-chained.check @@ -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` +================================================================================ diff --git a/test/files/presentation/completion-implicit-chained/Test.scala b/test/files/presentation/completion-implicit-chained/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/completion-implicit-chained/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest \ No newline at end of file diff --git a/test/files/presentation/completion-implicit-chained/src/Completions.scala b/test/files/presentation/completion-implicit-chained/src/Completions.scala new file mode 100644 index 0000000000..67922dfec0 --- /dev/null +++ b/test/files/presentation/completion-implicit-chained/src/Completions.scala @@ -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. +} -- cgit v1.2.3