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

Issues with Scala 2.13.7 #1417

Closed
mfirry opened this issue Nov 2, 2021 · 15 comments
Closed

Issues with Scala 2.13.7 #1417

mfirry opened this issue Nov 2, 2021 · 15 comments

Comments

@mfirry
Copy link

mfirry commented Nov 2, 2021

Hi all,
I think it's a bit weird that my code is not compiling with 2.13.7 but it does with 2.13.6.

Specifically with the following:

  val list = get(zero) {
    Ok(List(1, 2, 3).asJson)
  }

I now get

[error] /Users/pippo/personal/scala/web-frameworks-templates/finch/src/main/scala/WebServer.scala:22:17: overloaded method apply with alternatives:
[error]   (mapper: io.finch.internal.Mapper[cats.effect.IO,shapeless.HNil])io.finch.Endpoint[cats.effect.IO,mapper.Out] <and>
[error]   (input: io.finch.Input)io.finch.Endpoint.Result[cats.effect.IO,shapeless.HNil]
[error]  cannot be applied to (io.finch.Output[io.circe.Json])
[error]   val list = get(zero) {

(the complete code can be found here)

@rpless
Copy link
Collaborator

rpless commented Nov 2, 2021

I'm not sure what changed in 2.13.7 to cause this, but this version seems to have broken a bunch of things in the ecosystem. For the endpoints that don't take arguments to their mapping function you can fix them by adding an empty argument block:

val list = get(zero) { () =>
  Ok(List(1, 2, 3).asJson)
}

However the sayHi endpoint is still broken and I'm not quite sure why.

@SethTisue
Copy link
Contributor

This would have been caught ahead of time (before 2.13.7 was released) if Finch were in the Scala 2 community build.

I've opened a PR to add it, here: scala/community-build#1504

@gabro
Copy link

gabro commented Nov 2, 2021

FWIW there seems to be something odd with

implicit def mapperFromOutputValue[F[_], A](o: => Output[A])(implicit
F: MonadError[F, Throwable]
): Mapper.Aux[F, HNil, A] = instance(_.mapOutput(_ => o))

Given the error message, I would have expected the implicit conversion Output => Mapper to kick in, but it's clearly not happening

@mfirry
Copy link
Author

mfirry commented Nov 6, 2021

I was wondering if there is any way to trace and log implicit resolution (I think there is) and the check it with 2.13.7 and 2.13.6

@joroKr21
Copy link
Collaborator

joroKr21 commented Nov 6, 2021

I was wondering if there is any way to trace and log implicit resolution (I think there is) and the check it with 2.13.7 and 2.13.6

You can enable the -Xlog-implicits compiler option for that

@SethTisue
Copy link
Contributor

SethTisue commented Nov 22, 2021

We're aiming to build 2.13.8 circa Dec 10 (I'll be announcing this soon on contributors.scala-lang.org), so time is running short for a minimized bug report if you were hoping this might get fixed in that release.

@rpless
Copy link
Collaborator

rpless commented Nov 23, 2021

@SethTisue what would you consider ideal for a minimized bug report? Would extracting the failing finch examples from @mfirry's repo into a smaller self contained one be enough for a bug report on the Scala bug tracker? Or would it need to minimized further to exclude Finch entirely?

@SethTisue
Copy link
Contributor

It’s strongly preferable to have a reproduction without an external JAR involved, so that we can turn it directly into a regression test.

@mfirry
Copy link
Author

mfirry commented Nov 23, 2021

@rpless, happy to help. Let me know if this is useful => https://github.com/mfirry/finch-repro-1417

@rpless
Copy link
Collaborator

rpless commented Nov 23, 2021

Thanks @mfirry. I'm hoping we can get a repro without dependencies, but we'll see.

Did a little digging this morning. One thing I noticed is that this still compiles:

  val sayHello: Endpoint[IO, Buf] = get("hello" :: param[String]("one") :: param[String]("two"))(
    (one: String, two: String) =>
      Ok(Buf.Utf8(s"Hello, $one. Hello $two")))

Which kinda tells me that any Mapper that needs to summon a FnToProduct.Aux from shapeless still works. I suspect that means the only ones that are affected are the instances that get a raw Output or are a single arity function.
I'm gonna try to reduce finch down to something that can demonstrate this, but I'm unsure I'll have anything before the next Scala 2.13 release.
I also think this won't be an issue in Scala 3, based on the fact that we can remove the magnet pattern in #1407, so thats something. @sergeykolbasov not sure if you have any thoughts on this.

@joroKr21
Copy link
Collaborator

Perhaps scala/scala#9691 surfaced a diverging implicit error

@joroKr21
Copy link
Collaborator

This would fix it:

--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1101,10 +1101,10 @@ trait Infer extends Checkable {
                 enhanceBounds(adjusted.okParams, adjusted.okArgs, xs1)
                 xs1
             }
-          } else undetParams
+          } else if (context.implicitsEnabled) undetParams else Nil
         } catch ifNoInstance { msg =>
           NoMethodInstanceError(fn, args, msg)
-          undetParams
+          if (context.implicitsEnabled) undetParams else Nil
         }
       case x => throw new MatchError(x)
     }

Now all we need is a minimal reproduction and a ticket in scala/bug

@joroKr21
Copy link
Collaborator

What I missed in that PR was that if we are already typechecking an implicit view we can't recover with another implicit view.

@joroKr21
Copy link
Collaborator

I think we can safely close that now - it was a regression in Scala 2.13.7 and the fix will be released with 2.13.8

@mfirry
Copy link
Author

mfirry commented Jan 11, 2022

I confirm 2.13.8 fixes it for me. Thanks everyone!

@joroKr21 joroKr21 closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants