Skip to content
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

Do not harmonize constant args if their type doesn't affect resType #13353

Merged
merged 1 commit into from
Aug 23, 2021

Commits on Aug 22, 2021

  1. Do not harmonize constant args if their type doesn't affect resType

    Fixes the following sample from scala#9939:
    ```scala
    scala> f"${3.14}%.2f rounds to ${3}%d"
    1 |f"${3.14}%.2f rounds to ${3}%d"
      |                          ^
      |                          type mismatch;
      |                           found   : Double
      |                           required: Int
      | This location contains code that was inlined from rs$line$2:1
    ```
    
    At the moment when StringInterpolation transformation was performed instead
    of receiving `List(Constant(3.0), Constant(3))` arguments they
    were: `List(Constant(3.0), Constant(3.0))` (the second one was converted to double because of harmonization).
    That caused the reported type mismatch.
    
    In Scala2 harmonization doesn't happen if the resulting type is fully defined.
    For f-interp it shouldn't happen too as it's resulting type is a `String`:
    ```scala
      def f[A >: Any](args: A*): String = macro ???
    ```
    dos65 committed Aug 22, 2021
    Configuration menu
    Copy the full SHA
    8d7b856 View commit details
    Browse the repository at this point in the history