Skip to content

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

Closed
@milessabin

Description

@milessabin

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions