Skip to content

Commit 46211dd

Browse files
committed
Fix completion for synthetic case modules and methods
I'm pretty sure the `isSynthetic` call added in 854de25 should instead be `isArtifact`, so that's what I've implemented here. `isSynthetic` used to also filter out error symbols, which are created with the flags `SYNTHETIC | IS_ERROR`. I've added an addition test for `isError`, which was needed to keep the output of `presentation/scope-completion-import` unchanged. The checkfile for `presentation/callcc-interpreter` is modified to add the additional completion proposals: synthetic companion objects.
1 parent 0dbdaf8 commit 46211dd

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/interactive/scala/tools/nsc/interactive/Global.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
10001000
def add(sym: Symbol, pre: Type, implicitlyAdded: Boolean)(toMember: (Symbol, Type) => M) {
10011001
if ((sym.isGetter || sym.isSetter) && sym.accessed != NoSymbol) {
10021002
add(sym.accessed, pre, implicitlyAdded)(toMember)
1003-
} else if (!sym.name.decodedName.containsName("$") && !sym.isSynthetic && sym.hasRawInfo) {
1003+
} else if (!sym.name.decodedName.containsName("$") && !sym.isError && !sym.isArtifact && sym.hasRawInfo) {
10041004
val symtpe = pre.memberType(sym) onTypeError ErrorType
10051005
matching(sym, symtpe, this(sym.name)) match {
10061006
case Some(m) =>

test/files/presentation/callcc-interpreter.check

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reload: CallccInterpreter.scala
33
askTypeCompletion at CallccInterpreter.scala(51,34)
44
================================================================================
55
[response] askTypeCompletion at (51,34)
6-
retrieved 57 members
6+
retrieved 66 members
77
abstract trait Term extends AnyRef
88
abstract trait Value extends AnyRef
99
case class Add extends callccInterpreter.Term with Product with Serializable
@@ -50,6 +50,15 @@ final def synchronized[T0](x$1: T0): T0
5050
final def wait(): Unit
5151
final def wait(x$1: Long): Unit
5252
final def wait(x$1: Long,x$2: Int): Unit
53+
object Add
54+
object App
55+
object Ccc
56+
object Con
57+
object Fun
58+
object Lam
59+
object M
60+
object Num
61+
object Var
5362
private[this] val term0: callccInterpreter.App
5463
private[this] val term1: callccInterpreter.App
5564
private[this] val term2: callccInterpreter.Add

test/junit/scala/tools/nsc/interpreter/CompletionTest.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class CompletionTest {
8181

8282
checkExact(completer, "new C().x_y")("x_y_z")
8383
checkExact(completer, "(1 : O.T).toCha")("toChar")
84+
85+
intp.interpret("case class X_y_z()")
86+
val completer1 = new PresentationCompilerCompleter(intp)
87+
checkExact(completer1, "new X_y_")("X_y_z")
88+
checkExact(completer1, "X_y_")("X_y_z")
89+
checkExact(completer1, "X_y_z.app")("apply")
8490
}
8591

8692
@Test
@@ -137,8 +143,8 @@ class CompletionTest {
137143
def firstCompletionWithNoPrefixHidesUniversalMethodsAndExtensionMethods(): Unit = {
138144
val intp = newIMain()
139145
val completer = new PresentationCompilerCompleter(intp)
140-
checkExact(completer, "case class C(a: Int, b: Int) { this.")("a", "b")
141-
assert(Set("asInstanceOf", "==").diff(completer.complete("case class C(a: Int, b: Int) { this.").candidates.toSet).isEmpty)
146+
checkExact(completer, "class C(val a: Int, val b: Int) { this.")("a", "b")
147+
assert(Set("asInstanceOf", "==").diff(completer.complete("class C(val a: Int, val b: Int) { this.").candidates.toSet).isEmpty)
142148
checkExact(completer, "case class D(a: Int, b: Int) { this.a")("a", "asInstanceOf")
143149
}
144150

0 commit comments

Comments
 (0)