summaryrefslogtreecommitdiff
path: root/src/interactive/scala/tools/nsc/interactive/Global.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-04-30 05:25:10 -0700
committerPaul Phillips <paulp@improving.org>2013-04-30 08:13:02 -0700
commite6af9bcd0e68859a3bb71140342bb76c136714ee (patch)
tree2a4832267cc39d397783547b26ee23607a60e0ec /src/interactive/scala/tools/nsc/interactive/Global.scala
parentbf0db36d8bbb0ac7faa0652b98458cfebca8e78a (diff)
downloadscala-e6af9bcd0e68859a3bb71140342bb76c136714ee.tar.gz
scala-e6af9bcd0e68859a3bb71140342bb76c136714ee.tar.bz2
scala-e6af9bcd0e68859a3bb71140342bb76c136714ee.zip
SI-7362, crash in presentation compiler.
Code by retronym, test by huitseeker, I just move stuff around.
Diffstat (limited to 'src/interactive/scala/tools/nsc/interactive/Global.scala')
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala24
1 files changed, 11 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]