This is as expected, what’s happening is that at the point of constructing the tuple its argument types are already widened to (String, String), so the transparent inline def is still taking the most precise type of the right-hand-side.
Thanks, @bishabosha, I get that now it’s impossible. But I’m still curious if it’s already widened to (String, String)by design or because it’s just how it works now, i.e. can be a subject to change?
@hmf, yup, I already use mirrors to get the list of class members, but now I’m looking for a way to check at compile-time if a string present in a list (or a tuple, which is more likely to work out), i.e. I want some sort of compile-time List.contains. The YT channel is super cool by the way, never seen it before!
This is by design - all top level literal types are widened by default unless it is a final val or inline val. transparent inline def still widens but inline match is allowed to look at the type of the method body itself. By top level I mean the literal type would still be widened if it is the argument to some other type, e.g. List, or tuple types because the widening happens at the point of calling another constructor, method, etc.
There is SIP proposal #48 to let the user control when widening happens with a precise modifier on the type
By top level I mean the literal type would still be widened if it is the argument to some other type
It just stroke me that this might be somehow related to a bugreport I filled in yesterday (not related to the initial discourse post at all). If this is indeed related - what you’re saying might mean that the bugreport is false and what we’re trying to do there is impossible by design. If you by any chance can look at it - that’d be awesome.