-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #3337 - Repl CompanionObject #3369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
@@ -29,6 +29,9 @@ class TabcompleteTests extends ReplTest { | |||
comp.suggestions.sorted == List("slice", "sliding")) | |||
} | |||
|
|||
@Test def classModuleHiding: Unit = | |||
fromInitialState{ implicit s => assert(tabComplete("scala.Predef").suggestions.isEmpty) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name the test tabCompleteModule
and add this to the test:
fromInitialState { implicit s =>
val comp = tabComplete("scala.Pre")
assertEquals(comp.suggestions, List("Predef"))
}
@Test def tabCompleteModule: Unit = | ||
fromInitialState{ implicit s => | ||
val comp = tabComplete("scala.Pred").suggestions | ||
assertTrue(s""""Expected single element "Predef" got: ${comp}""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need braces after $
when you only have an identifier: $comp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I actually think it is better to use: assertEquals(comp.suggestions, List("Predef"))
than assertTrue
. The message will be automatically generated.
if (ch <= nops && repl != null) | ||
repl | ||
else ch | ||
}.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to push this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, i rebased, sorry
8db7b3f
to
e76e7cd
Compare
I'll let @smarter confirm that it is the right fix
@@ -105,6 +105,7 @@ object Interactive { | |||
buf ++= prefix.member(name).altsWith{ d => | |||
!d.isAbsent && | |||
!d.is(Synthetic) && !d.is(Artifact) && | |||
!d.is(ModuleClass) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a better fix possible. Notice that we use completionsFilter
to restrict the symbols we complete on, the definition below is:
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean =
!name.isConstructorName && name.is(SimpleNameKind)
This is supposed to filter out all the non-simple names but the check is wrong: name.is(SimpleNameKind)
will also return true if the underlying name kind is SimpleNameKind
, the check should be replaced by name.toTermName.info.kind == SimpleNameKind
. If you do this then you won't have to explicitly filter out ModuleClass
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for explanation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please squash all commits into one since there's only one functional change in the end.
Also I'll note in passing that there's another use of |
9536b09
to
7c1434c
Compare
@smarter done 👍 |
by adding check if
ModuleClass