scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Fail self-recursive deferred given impl

Open som-snytt opened this issue 10 months ago • 3 comments

At typer, fail if implementing a deferred given picks the implementing member, which can happen in the companion to the type class.

The recursion is not detected by CheckLoopingImplicits, where a warning might have sufficed, because the RHS gets the symbol of the deferred member and not its implementation.

It behooves typer to refuse to infer the member in this case.

The feature is intended to reduce boilerplate where the implicit value is found in lexical scope, so that not too much magic is demanded.

Fixes #22589

som-snytt avatar Feb 13 '25 01:02 som-snytt

It's harder for me to re-review in squashed form. It looks like a minor refactor to reuse the reporting and also make the if/else easier to read. The resolvedHere bit is new.

I guess "squash, rebase, merge" preserves history as long as possible. It would be great if github had a feature to create an unsquashed/ branch that is only visible if you ask for it by clicking a widget.

som-snytt avatar Mar 08 '25 18:03 som-snytt

rebased

som-snytt avatar Apr 28 '25 18:04 som-snytt

Refactored responsibleForImports fix to a def for scoping; that conflicted with the previous refactor to reduce the big else branch.

Also refactored the previous warning to rhs.tap(warn), also for scoping. The near pun is tap(warn) and tapeworm. The usual pun is warn and worn, which also applies.

That was three months ago.

som-snytt avatar May 26 '25 20:05 som-snytt

Added a test for the six month anniversary and rebased. I was already asked to squash.

som-snytt avatar Aug 21 '25 13:08 som-snytt

Minimized the diff.

som-snytt avatar Oct 28 '25 08:10 som-snytt