Skip to content

Duplication of companion methods after using FromTasty fixed #978

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

Conversation

VladimirNik
Copy link
Contributor

Fix for: #977

The problem was due to scalacLinkedClass method invocation during unpickling. Companion methods should be generated only if symbol returned by scalacLinkedClass is among unpickled symbols.

Review by @odersky, @DarkDimius

@@ -590,7 +590,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
case TYPEDEF | TYPEPARAM =>
if (sym.isClass) {
val companion = sym.scalacLinkedClass
if (companion != NoSymbol) {
if (companion != NoSymbol && symAtAddr.valuesIterator.contains(companion)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not symAtAddr.contains(companion)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DarkDimius because symAtAddr is a map, key is an address, and to fix the problem we need to see values of this map.

Copy link
Contributor

Choose a reason for hiding this comment

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

valuesIterator takes linear time to check if element is contained.
It means that this change makes reading tasty quadratic in number of TypeDefs.

if companion != NoSymbol, where does companion originate from if not from Tasty? ClassPath?

@VladimirNik VladimirNik force-pushed the companion-methods-duplication branch from d0d3629 to 62c7458 Compare November 25, 2015 21:39
@VladimirNik VladimirNik force-pushed the companion-methods-duplication branch from 62c7458 to 0afb2a3 Compare November 25, 2015 21:41
@DarkDimius
Copy link
Contributor

LGTM

DarkDimius added a commit that referenced this pull request Nov 26, 2015
Duplication of companion methods after using FromTasty fixed
@DarkDimius DarkDimius merged commit ec2d0e4 into scala:master Nov 26, 2015
@allanrenucci allanrenucci deleted the companion-methods-duplication branch December 14, 2017 16:58
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.

3 participants