why does `reified` have to be declared explicitly ...
# announcements
l
why does
reified
have to be declared explicitly ? are there cases where you'd want the type parameter of an
inline
function to NOT be reified ?
2
k
Yes, see the following snippet
Copy code
class Foo<T>(val obj:T) {
	fun bar() = test(obj) //error
}

inline fun <reified T> test(i: T) = i
calling
test(obj)
does not work when
T
in
test
is
reified
, as Foo doesn't actually know what
T
is. However if
T
is no longer
reified
then
bar
can call
test(obj)
without any issues.
h
can't the compiler just tell us that, then?
i guess the question is whether coders write functions leveraging any mutual exclusivity between declaring or not declaring
reified
(probably) either way making the
reified
implicit likely would break backwards compatibility so likely never gonna happen
k
can't the compiler just tell us that, then?
What do you mean?