-
Notifications
You must be signed in to change notification settings - Fork 21
Implicit def not found if it occurs later in same file #1814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-1814?orig=1 |
David Greenspan (dgreensp) said: |
@DRMacIver said: |
@paulp said: implicit def string2FooString(s: String): FooString = new FooString(s) That works. //println(string2FooString("%s = %s") % ("foo", "bar")); // this line causes next line to compile! That works because calling it explicitly causes the return type to be resolved. // if this module is moved to the top of the file, the code compiles That works because then the implicit's return type is resolved before it gets to the operation which needs it. |
@paulp said: "I have implemented a slightly more permissive rule: An implicit conversion without explicit result type is visible only in the text following its own definition. That way, we avoid the cyclic reference errors. I close for now, to see how this works. If we still have issues we migth come back to this." |
In the following code, whether an implicit conversion is found by the compiler depends on the order of modules in the file, and on whether the method is called explicitly in a seperate statement:
The text was updated successfully, but these errors were encountered: