Transitive implicits

Givens don’t seem to apply transitively. Is there a way to make them transitive? For example, can the code below be changed to compile, without explicitly adding a given for A in C? Can the given for A in B somehow be made available in C?

class A

class B:
  given A = new A()

class C:
  given B = new B()
  usingA // No given instance of type A was found...

def usingA(using A): Unit = ()

You can import B.give inside C

1 Like

I just tried adding import B.given inside C, but the error remains the same…

Sorry, I am still not used to this given syntax. And I forgot B there would not be the identifier.

1 Like

Thanks! Too bad import summon[B].given doesn’t work.

val b = summon[B]
import b.given

if you prefer.

1 Like

Actually it’s just a syntax restriction. If summon is defined like this then import summon.given works:

inline transparent def summon(using b: B) = b

It’s only the syntax that doesn’t accept [] in import statements. IMHO that would be a good feature request.