Skip to content
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

Semanticdb usability enhancements #9768

Merged
merged 5 commits into from
Sep 28, 2020

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Sep 10, 2020

This has a bunch of enhancements,

@bishabosha bishabosha changed the title Semanticdb changes usability Semanticdb usability enhancements Sep 10, 2020
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Thanks for the great work! LGTM I left just a single question, though that might be obvious.

suit/*->_empty_::Enums.Suits.extension_isRed().(suit)*/ ==/*->scala::Any#`==`().*/ Hearts/*->_empty_::Enums.Suits.Hearts.*/ ||/*->scala::Boolean#`||`().*/ suit/*->_empty_::Enums.Suits.extension_isRed().(suit)*/ ==/*->scala::Any#`==`().*/ Diamonds/*->_empty_::Enums.Suits.Diamonds.*/

extension (suit/*<-_empty_::Enums.Suits.extension_isBlack().(suit)*/: Suits/*->_empty_::Enums.Suits#*/) def isBlack: Boolean /*<-_empty_::Enums.Suits.extension_isBlack().*//*->scala::Boolean#*/= suit/*->_empty_::Enums.Suits.extension_isBlack().(suit)*/ match
extension (suit/*<-_empty_::Enums.Suits.extension_isBlack().(suit)*/: Suits/*->_empty_::Enums.Suits#*/) def isBlack/*<-_empty_::Enums.Suits.extension_isBlack().*/: Boolean/*->scala::Boolean#*/ = suit/*->_empty_::Enums.Suits.extension_isBlack().(suit)*/ match
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the name be something like extension-isBlack(). ? I think we can't name a method like that, but we can name a method extension_isBlack Or is that not an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I'm not sure what you mean

Copy link
Contributor

Choose a reason for hiding this comment

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

I am just wondering what is the string representation for extension methods (since basically everything is represented by string in semanticdb) and can it not conflict with a normal method in the class prefixed with extension_
It is highly unlikely that a method like that will be created, but I wonder if we should maybe change the string representation for extension methods.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, there is a check in desugaring that proves only extension methods can have that prefix, although its probably not been enforced in macros

Copy link
Member Author

Choose a reason for hiding this comment

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

actually it seems val/vars can also have this name 😕

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about using extension- to signal it's an extension? We can't use - in the name so it should be good.

Copy link
Member Author

Choose a reason for hiding this comment

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

so extension [T,U](t: T) def <*>: (T,U) = ??? would be extension-`<*>`().?

Copy link
Member Author

Choose a reason for hiding this comment

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

the other alternative is that we add another Property kind (alongside FINAL, SEALED, etc.)

@smarter smarter assigned bishabosha and unassigned smarter Sep 18, 2020
@bishabosha bishabosha assigned smarter and unassigned bishabosha Sep 18, 2020
Comment on lines 346 to 348
var length = realName.length
if symbol.is(ExtensionMethod) && name.isExtensionName then
length -= "extension_".length
Copy link
Member

Choose a reason for hiding this comment

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

Not essential but it might be nicer to have a stripExtensonMethodPrefix just like we have a stripModuleClassSuffix (are there other situations where we need to strip the extenson_ prefix?)

Copy link
Member Author

Choose a reason for hiding this comment

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

there is the dropExtension method but its only used for import suggestions so far

@bishabosha
Copy link
Member Author

bishabosha commented Sep 18, 2020

cats.effect.concurrent.MVarConcurrentTests failed in the community build

@smarter
Copy link
Member

smarter commented Sep 18, 2020

Try rebasing, it should be fixed now

@bishabosha
Copy link
Member Author

rebased and added a check to look in the mods also

else {
val realName = name.stripModuleClassSuffix.lastPart
Span(point, point + realName.length, point)
var length = realName.length
if (mods.is(ExtensionMethod) || symbol.is(ExtensionMethod)) && name.isExtensionName then
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the symbol.is(ExtensionMethod) check necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was told once that mods may not always be copied over beyond some phase but I'm not sure about this

@bishabosha bishabosha merged commit 374eb94 into scala:master Sep 28, 2020
@bishabosha bishabosha deleted the semanticdb-changes-usability branch September 28, 2020 13:08
@liufengyun
Copy link
Contributor

This PR breaks the master.

@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SemanticDB occurrence for default contructor should be zero length
6 participants