I think I found a compiler frontend bug. Can you g...
# announcements
p
I think I found a compiler frontend bug. Can you guys get this piece to compile?
Copy code
class A

inline fun <reified T> A.foo(): T = TODO("Not necessary to implement")

open class B {
    val a = A()
    inline fun <reified T> foo() = bar { foo() }
    fun <T> bar(baz: A.() -> T) = a.baz()
    companion object : B()
}
g
Renaming A.foo to something else should do the trick
(or B.foo)
p
I got to fix it, yes, but I think the compiler should have a more graceful error
it says
internal error
to me
k
Interesting, renaming A.foo doesn't work
g
at least in a scratch file it also prints a stack trace, which says the problem is recursion
there should be a way to specify that you're referencing the foo on A, such as this@A.foo, but that doesn't work
k
I'm guessing someting with a cyclic type or something
Using
inline fun <reified T> foo():T = bar { this.foo() }
seems to work
g
I got it to work in a scratch using the following:
Copy code
class A {
    inline fun A.fooA(): Unit = TODO("Not necessary to implement")
}

open class B {
    val a = A()
    inline fun <reified T> foo() = bar { fooA() }
    fun <T> bar(baz: A.() -> T) = a.baz()
    companion object : B()
}
interestingly enough, it doesn't work if fooA is an extension. Don't know why though
k
I think it's caused by the fact extension functions have less priority than member functions.
g
While that is true, this only come into play when there are conflicts. There is only one fooA defined, so it shouldn't matter whether it's defined as an extension or a member
k
You removed the
reified T
p
specifying the returned types in the B functions fixes it, but my point is that nothing should be breaking the compiler 😛
g
it's not the first nor the last unfortunately 🙂