Nobody expects to import toString #22594
Labels
area:import
Issues tied to imports.
area:repl
area:reporting
Error reporting including formatting, implicit suggestions, etc
itype:bug
Compiler version
3.6.3
Minimized code
Output
Expectation
When I'm really frazzled and trying to debug, don't mess with me, just print the string.
The example is from vulpix, where the local import was 100 lines earlier in the source.
This came up in Scala 2 implementation of the ambiguity for inherited vs definitions in scope. That was at scala/scala#10220 (comment) where an exception for
toString
was deemed too special.Scala 2 disallows importing universal members from root imports. There is a ticket for package object members referenced by top level defs.
So there is precedent for placing limits on these behaviors which sacrifice convenience and intuition to regularity.
In a template nesting level, an import is shadowed by an inherited member, but a local import wins.
A possible limit would be to always disallow import of universal members by wildcard import (including root imports).
(Whether to detune the ambiguity for inherited vs scope is a separate issue, but worth considering.)
The text was updated successfully, but these errors were encountered: