Skip to content

Fix #9568: Disallow partially undefined types as byname anchors #9575

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 2 commits into from
Aug 17, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 17, 2020

Require that the type that a by-name implicit can recursively implement
must be fully defined.

@@ -1371,8 +1376,12 @@ trait Implicits:
history match
case prev @ OpenSearch(cand1, tp, outer) =>
if cand1.ref eq cand.ref then
def checkFullyDefined =
val result = isFullyDefined(tp, ForceDegree.failBottom)
Copy link
Member

Choose a reason for hiding this comment

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

What would happen if we forced the type to be fully defined at that point instead of disqualifying it?

Copy link
Member

Choose a reason for hiding this comment

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

I guess it will only be disqualified if a type variable would be instantied to Nothing, but that might be a legitimate instantiation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I don't know what is the right force degree, or whether there even is one.

Copy link
Member

@smarter smarter Aug 17, 2020

Choose a reason for hiding this comment

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

I've tried setting the force degree to all which changes how we do error reporting but seems to be fine, let me know what you think.

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 think that's fine, too. It's a corner case, so the simpler the handling the better.

Require that the type that a by-name implicit can recursively implement
must be fully defined.
@smarter smarter force-pushed the fix-#9568 branch 2 times, most recently from 36e0755 to e8b94f0 Compare August 17, 2020 13:46
@smarter smarter assigned odersky and unassigned smarter Aug 17, 2020
Nothing has legitimate use as a type parameter, so special-casing
inference to reject it can cause issues. Also by removing this
special-case we can remove the error reporting logic dedicated to
dealing with non-fully-defined types, instead the user will see that a
type parameter was instantiated to `Nothing` in the error which should
be clear enough.
@odersky odersky merged commit 71e9e21 into scala:master Aug 17, 2020
@odersky odersky deleted the fix-#9568 branch August 17, 2020 20:07
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.

2 participants