You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
opaquetypeOpaque=Inttransparentinlinedefop:Opaque=123objectMain {
defmain(args: Array[String]):Unit= {
valo:Opaque=123// OK: does not compilevalo2:Opaque= op // BUG: Does not compile because inferred type is int, but should compile
}
}
Expectation
In my opinion, the inferred type of o2 should be Opaque since Opaque is not transparent within Main. If the RHS of the opaque type is a private class, it manages to escape its scope and is inferred here even if it is not visible.
The text was updated successfully, but these errors were encountered:
It depends. If the type were Opaque & Int, then val o2: Opaque = op should compile, right? I encountered this problem mostly when writing transparent def macros and found that when the written type of the transparent method is fully qualified, then an intersection is inferred; when it is not fully qualified (and the transparent method is defined in the opaque type's transparent scope), then only the RHS is inferred. So it definitely also depends on the scope of the transparent method and possibly other factors.
Compiler version
3.3.3
Minimized code
Expectation
In my opinion, the inferred type of
o2
should beOpaque
sinceOpaque
is not transparent withinMain
. If the RHS of the opaque type is a private class, it manages to escape its scope and is inferred here even if it is not visible.The text was updated successfully, but these errors were encountered: