Skip to content

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

Merged
merged 1 commit into from
Oct 26, 2017
Merged

Conversation

rsoeldner
Copy link
Contributor

by adding check if ModuleClass

Copy link
Member

@dottybot dottybot left a 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) }
Copy link
Contributor

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}""",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation

Copy link
Contributor

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

Copy link
Contributor

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()
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, i rebased, sorry

@allanrenucci allanrenucci requested a review from smarter October 23, 2017 19:07
@allanrenucci allanrenucci dismissed their stale review October 23, 2017 19:09

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) &&
Copy link
Member

@smarter smarter Oct 23, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for explanation!

Copy link
Member

@smarter smarter left a 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.

@smarter
Copy link
Member

smarter commented Oct 26, 2017

Also I'll note in passing that there's another use of is(SimpleNameKind) in https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/repl/ReplDriver.scala#L261 that should probably be changed too, although I haven't checked it exactly what it does.

@rsoeldner
Copy link
Contributor Author

@smarter done 👍

@smarter smarter merged commit 0202822 into scala:master Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants