Skip to content

Fix #7060: Make single-parameter constrained more versatile #7065

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 26, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 19, 2019

No description provided.

@@ -503,7 +503,8 @@ object ProtoTypes {
}

/** Same as `constrained(tl, EmptyTree)`, but returns just the created type lambda */
Copy link
Member

Choose a reason for hiding this comment

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

The documentation is now misleading, also is there a reason why alwaysAddTypeVars = ctx.typerState.isCommittable is not a good default for the other overload ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would be a good default, except that the default value would refer to the ctx which follows.

Make single-parameter `constrained` more versatile by using a smarter default value for
`alwaysAddTypeVars`.
val state = ctx.typerState
val addTypeVars = alwaysAddTypeVars || !owningTree.isEmpty
if (tl.isInstanceOf[PolyType])
assert(!(ctx.typerState.isCommittable && !addTypeVars),
assert(!ctx.typerState.isCommittable || addTypeVars,
s"inconsistent: no typevars were added to committable constraint ${state.constraint}")
Copy link
Member

Choose a reason for hiding this comment

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

If we change the assertion then this message also needs to be updated I think:

Suggested change
s"inconsistent: no typevars were added to committable constraint ${state.constraint}")
s"inconsistent: typevars were added to non-committable constraint ${state.constraint}")

Copy link
Member

Choose a reason for hiding this comment

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

ah nevermind I got confused, the current message is correct.

@odersky odersky merged commit b5df0a3 into scala:master Aug 26, 2019
@odersky odersky deleted the fix-#7060 branch August 26, 2019 13:03
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