-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix widen types before checking an implicit view exists #18719
Conversation
The implementation here comes from porting from nsc. But I think things were done differently enough with its Global state, that make it not translate nicely here. So I'm paring it down to what I know works (at least for me): versions, settings, compilation unit. Not the tree/symbol/site stuff.
It's not possible to convert a method, such as a polymorphic method, such as `makeChurch`, into another type - we need to widen out the TermRef to discover the underlying PolyType which isn't a value type. Failing to do so will create a dummyTreeOfType, which will then be attempted to be applied, which eventually causes an assertion crash while building the tpd.TypeApply.
@@ -850,7 +850,7 @@ trait Implicits: | |||
&& !to.isError | |||
&& !ctx.isAfterTyper | |||
&& ctx.mode.is(Mode.ImplicitsEnabled) | |||
&& from.isValueType | |||
&& from.widen.isValueType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Counter-example:
given foo[A]: (Ctx => Int) = _ => 42
val works = get[Int](using summon[Ctx => Int])
val fails = get[Int]
using the example from #16453 - with this change (or !imp.underlying.isInstanceOf[PolyType]
in ignoredConvertibleImplicits
) the suggestion of foo
will be dropped, even though it's a correct suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, both the improvements to enriched error messages and the fix in Implicits.
…singleton types This is an alternative fix for scala#18695, which already got fixed in a different way by scala#18719. This PR adds the actual tests, and leaves in the fix as a defensive measure in case the situation arises by some other means than the one foxed in scala#18719.
Tweaked in #18727. |
Using issue #18650 as the reference (but issue #18999 is another option) building on the fix in PR #18719 (refined in PR #18727) as well as the fix in PR #18760, I'm trying to make a more root change here by making sure that message forcing only occurs with `hasErrors`/`errorsReported` is true, so as to avoid assertion errors crashing the compiler.
Using issue scala#18650 as the reference (but issue scala#18999 is another option) building on the fix in PR scala#18719 (refined in PR scala#18727) as well as the fix in PR scala#18760, I'm trying to make a more root change here by making sure that message forcing only occurs with `hasErrors`/`errorsReported` is true, so as to avoid assertion errors crashing the compiler. (cherry picked from commit 10f2c10)
Using issue scala#18650 as the reference (but issue scala#18999 is another option) building on the fix in PR scala#18719 (refined in PR scala#18727) as well as the fix in PR scala#18760, I'm trying to make a more root change here by making sure that message forcing only occurs with `hasErrors`/`errorsReported` is true, so as to avoid assertion errors crashing the compiler. (cherry picked from commit 10f2c10)
Fixes #18650