Skip to content

Check for symbol existence when working with GADT bounds in TypeComparer #6431

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 4 commits into from
May 3, 2019

Conversation

milessabin
Copy link
Contributor

Without the guard the test case crashes with an assert attempting get the owner of NoSymbol.

Without the guard the test case crashes with an assert attempting get
the owner of NoSymbol.
@milessabin milessabin requested a review from abgruszecki May 2, 2019 17:10
@smarter
Copy link
Member

smarter commented May 2, 2019

You can use .maybeOwner instead of .owner to handle NoSymbol.

@milessabin
Copy link
Contributor Author

milessabin commented May 3, 2019

I don't think that's going to help here ... the .owner call is in SymDenotation#typeRef, and I'm hesitant to make this change there.

I could move the check into gadtBounds and have it return null if it's called on NoSymbol ... do you think that'd be preferable?

@smarter
Copy link
Member

smarter commented May 3, 2019

What do you think @AleksanderBG ?

@milessabin
Copy link
Contributor Author

The previous CI failures were all timeouts, BTW.

@milessabin
Copy link
Contributor Author

Urgh ...

We need a style guide for this or something. FWIW there are a bunch of eq/ne NoSymbol in TypeComparers ... I copied those usages.

else {
footprint += sym.typeRef
super.gadtBounds(sym)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC that the problem is with NoSymbol.typeRef exploding, I'd prefer

if (sym.exists) footprint += sym.typeRef
super.gadtBounds(sym)

instead, because 1) this matters for logging 2) it should ultimately be the business of GadtConstraint to decide what to return for unconstrained symbols.

Otherwise LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That looks fine.

There's similar code in the neighbouring gadtAddLowerBound and gadtAddUpperBound ... make the same change there as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've gone ahead and done that. Will merge when green.

@milessabin milessabin changed the title Guard against NoSymbol in compareGADT Check for symbol existence when working with GADT bounds in TypeComparer May 3, 2019
@milessabin milessabin merged commit d78b8c0 into scala:master May 3, 2019
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