Skip to content

Mixing by-name implicits and inlining results in broken owner chains #5766

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

Closed
milessabin opened this issue Jan 21, 2019 · 0 comments · Fixed by #5767
Closed

Mixing by-name implicits and inlining results in broken owner chains #5766

milessabin opened this issue Jan 21, 2019 · 0 comments · Fixed by #5767
Assignees

Comments

@milessabin
Copy link
Contributor

The following,

trait Foo { def next: Foo }

inline implicit def foo(implicit loop: => Foo): Foo = new Foo { def next = loop }

def summon(implicit f: Foo) = ()
summon

crashes the compiler with,

Exception in thread "main" java.lang.AssertionError: assertion failed: failure to
construct path from method next/anonymous class Object with Test1.Foo{...}/value
<local Test1$>/object Test1/package <empty>/package <root> to `this` of
class $_lazy_implicit_$2;
anonymous class Object with Test1.Foo{...} does not have an outer accessor

This is the inlining equivalent of a similar interaction between by-name implicits and macros in scalac and reported and fixed here: scala/scala#7199.

The Dotty fix is quite similar ... PR incoming.

@milessabin milessabin self-assigned this Jan 21, 2019
milessabin added a commit to milessabin/dotty that referenced this issue Jan 21, 2019
When constructing the dictionary for a byname implicit resolution we
have to ensure that the owners of any definitions which have been
hoisted into the dictionary are correct. Prior to this PR this was only
done fully for implicit expansions which didn't involve inlining. We fix
that here by ensuring that all definitions under a given dictionary
entry are owned directly or indirectly by that dictionary entry.

Fixes scala#5766.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant