Skip to content

fix #2166: unpickling of shared CaseDef #2187

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
Apr 6, 2017

Conversation

liufengyun
Copy link
Contributor

Fix #2166: the unpickling of CaseDef should take care of SHARED trees.

@smarter
Copy link
Member

smarter commented Apr 4, 2017

Missing test case?

@liufengyun
Copy link
Contributor Author

The pickling tests pass, but the bootstrap pickling failed. Need to investigate further.

@@ -1062,7 +1062,13 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
}

def readCases(end: Addr)(implicit ctx: Context): List[CaseDef] =
collectWhile(nextByte == CASEDEF && currentAddr != end) { readCase()(ctx.fresh.setNewScope) }
collectWhile(nextByte == CASEDEF | nextByte == SHARED && currentAddr != end) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you want ||, not |

Copy link
Member

@smarter smarter Apr 4, 2017

Choose a reason for hiding this comment

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

And you also need to put parens in the correct place because && has higher precedence:

(nextByte == CASEDEF || nextByte == SHARED) && currentAddr != end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot @smarter , I owe you a beer 👍 I will no longer claim I can write Scala in my CV :)

@@ -1062,7 +1062,13 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
}

def readCases(end: Addr)(implicit ctx: Context): List[CaseDef] =
collectWhile(nextByte == CASEDEF && currentAddr != end) { readCase()(ctx.fresh.setNewScope) }
collectWhile((nextByte == CASEDEF || nextByte == SHARED) && currentAddr != end) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simply use nextUnsharedTag for this.

collectWhile(nextUnsharedTag == CASEDEF && currentAddr != end) { readCase()(ctx.fresh.setNewScope) }

@odersky
Copy link
Contributor

odersky commented Apr 6, 2017

Sorry, that was a wrong comment. In fact your original version is the correct one.

@odersky odersky merged commit 49a18da into scala:master Apr 6, 2017
@allanrenucci allanrenucci deleted the fix-2166 branch December 14, 2017 19:19
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