summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala24
-rw-r--r--test/files/presentation/t1207.check53
-rw-r--r--test/files/presentation/t1207/Test.scala3
-rw-r--r--test/files/presentation/t1207/src/Completions.scala20
4 files changed, 87 insertions, 13 deletions
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index 792ca6efa6..b6f4779bc4 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -1033,23 +1033,21 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
private def typeMembers(pos: Position): Stream[List[TypeMember]] = {
- var tree = typedTreeAt(pos)
-
- // if tree consists of just x. or x.fo where fo is not yet a full member name
- // ignore the selection and look in just x.
- tree match {
- case Select(qual, name) if tree.tpe == ErrorType => tree = qual
- case _ =>
+ // Choosing which tree will tell us the type members at the given position:
+ // If pos leads to an Import, type the expr
+ // If pos leads to a Select, type the qualifier as long as it is not erroneous
+ // (this implies discarding the possibly incomplete name in the Select node)
+ // Otherwise, type the tree found at 'pos' directly.
+ val tree0 = typedTreeAt(pos) match {
+ case sel @ Select(qual, _) if sel.tpe == ErrorType => qual
+ case Import(expr, _) => expr
+ case t => t
}
-
val context = doLocateContext(pos)
-
- if (tree.tpe == null)
- // TODO: guard with try/catch to deal with ill-typed qualifiers.
- tree = analyzer.newTyper(context).typedQualifier(tree)
+ // TODO: guard with try/catch to deal with ill-typed qualifiers.
+ val tree = if (tree0.tpe eq null) analyzer newTyper context typedQualifier tree0 else tree0
debugLog("typeMembers at "+tree+" "+tree.tpe)
-
val superAccess = tree.isInstanceOf[Super]
val members = new Members[TypeMember]
diff --git a/test/files/presentation/t1207.check b/test/files/presentation/t1207.check
new file mode 100644
index 0000000000..0ff7dbcd1e
--- /dev/null
+++ b/test/files/presentation/t1207.check
@@ -0,0 +1,53 @@
+reload: Completions.scala
+
+askTypeCompletion at Completions.scala(10,15)
+================================================================================
+[response] aksTypeCompletion at (10,15)
+retrieved 3 members
+[accessible: true] `package bongoother.bongo.type`
+[accessible: true] `package langother.lang.type`
+[accessible: true] `package utilother.util.type`
+================================================================================
+
+askTypeCompletion at Completions.scala(11,16)
+================================================================================
+[response] aksTypeCompletion at (11,16)
+retrieved 3 members
+[accessible: true] `package bongoother.bongo.type`
+[accessible: true] `package langother.lang.type`
+[accessible: true] `package utilother.util.type`
+================================================================================
+
+askTypeCompletion at Completions.scala(12,19)
+================================================================================
+[response] aksTypeCompletion at (12,19)
+retrieved 3 members
+[accessible: true] `package bongoother.bongo.type`
+[accessible: true] `package langother.lang.type`
+[accessible: true] `package utilother.util.type`
+================================================================================
+
+askTypeCompletion at Completions.scala(13,19)
+================================================================================
+[response] aksTypeCompletion at (13,19)
+retrieved 3 members
+[accessible: true] `package bongoother.bongo.type`
+[accessible: true] `package langother.lang.type`
+[accessible: true] `package utilother.util.type`
+================================================================================
+
+askTypeCompletion at Completions.scala(14,23)
+================================================================================
+[response] aksTypeCompletion at (14,23)
+retrieved 3 members
+[accessible: true] `package bongoother.bongo.type`
+[accessible: true] `package langother.lang.type`
+[accessible: true] `package utilother.util.type`
+================================================================================
+
+askTypeCompletion at Completions.scala(15,10)
+================================================================================
+[response] aksTypeCompletion at (15,10)
+retrieved 0 members
+
+================================================================================
diff --git a/test/files/presentation/t1207/Test.scala b/test/files/presentation/t1207/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t1207/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/t1207/src/Completions.scala b/test/files/presentation/t1207/src/Completions.scala
new file mode 100644
index 0000000000..804d4fdc3d
--- /dev/null
+++ b/test/files/presentation/t1207/src/Completions.scala
@@ -0,0 +1,20 @@
+package other {
+ package bongo { }
+ package lang { }
+ package util {
+ package boogly
+ }
+}
+
+package ticket_1001207 {
+ import other./*!*/
+ import other.u/*!*/
+ import other.uti /*!*/
+ import other.util/*!*/
+ import other.{lang, u/*!*/}
+ import j/*!*/
+
+ class T1207 {
+
+ }
+}