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

scala3: compile akka-http-core and pass all its tests #4097

Merged
merged 19 commits into from
Apr 11, 2022

Conversation

hughsimpson
Copy link
Contributor

@hughsimpson hughsimpson commented Apr 8, 2022

  • Enables and passes all tests in akka-http-core for scala 3.1.1 and 2.13.8
  • All files in that module deduplicated between scala-2 and scala-3

References #4079, task "akka-http-core"

@lightbend-cla-validator
Copy link

Hi @hughsimpson,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

https://www.lightbend.com/contribute/cla

: TailSwitch[L, T, R] { type Out = TailSwitch0[L, L, T, T, R, HNil] } = `n/a`
implicit def tailSwitch[L <: _ :: _, T <: _ :: _, R <: HList]
: TailSwitch[L, T, R] { type Out = TailSwitch0[L, L, T, T, R, HNil] } = `n/a`
/// Optimisations to reduce compilation times to something tolerable
Copy link
Contributor Author

@hughsimpson hughsimpson Apr 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to solve the general issue, but having some special-case implicits to short-circuit logic in certain common patterns seems to be enough for the usages in akka-http to compile

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been trying to solve this in a more general way but it looks like this would require some fixes/optimizations in the compiler itself.

Copy link
Contributor Author

@hughsimpson hughsimpson Apr 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had the same feeling... I poked around a little but it looks like the main issue is that the compiler is 'surprisingly slow' at evaluating the compile-time type reduction. Since it blows up so quickly, I guess some resolution stage must be the wrong O...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway apologies for stepping on your toes with this one. I got rather carried away testing that the workaround held good for all the cases we encounter in the parsers 😅

@hughsimpson hughsimpson changed the title Compile akka http core Compile akka-http-core Apr 8, 2022
@hughsimpson
Copy link
Contributor Author

Have signed CLA

@@ -100,14 +100,14 @@ private[parser] trait SimpleHeaders { this: Parser with CommonRules with CommonA

// http://tools.ietf.org/html/rfc7233#section-4.2
def `content-range` = rule {
(`byte-content-range` | `other-content-range`) ~ EOI ~> (`Content-Range`(_, _))
(`byte-content-range` ~ EOI ~> (`Content-Range`(_, _)) | `other-content-range` ~ EOI ~> (`Content-Range`(_, _)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original form is thrown off by the different subtypes, but this doesn't feel too bad an expansion...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agreed.

@@ -72,7 +75,7 @@ abstract class AkkaSpec(_system: ActorSystem)

def this() = this(ActorSystem(AkkaSpec.getCallerName(getClass), AkkaSpec.testConf))

val log: LoggingAdapter = Logging(system, this.getClass)
val log: LoggingAdapter = Logging(system, this.getClass.asInstanceOf[Class[Any]])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this one TBQH...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried variations but also failed to come up something better. It seems some automatic conversions wrt to Java wildcard types don't work as well (or at least different) in Scala 3 than before.

@jrudolph
Copy link
Contributor

Wow, great that you tackled this, @hughsimpson! I'm going to have a thorough look later.

Copy link
Contributor

@jrudolph jrudolph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great. The only thing that probably needs fixing is the error message assertions in tests to make sure they work for both Scala 2 and Scala 3. I'll have a look what's going on there.

@@ -100,14 +100,14 @@ private[parser] trait SimpleHeaders { this: Parser with CommonRules with CommonA

// http://tools.ietf.org/html/rfc7233#section-4.2
def `content-range` = rule {
(`byte-content-range` | `other-content-range`) ~ EOI ~> (`Content-Range`(_, _))
(`byte-content-range` ~ EOI ~> (`Content-Range`(_, _)) | `other-content-range` ~ EOI ~> (`Content-Range`(_, _)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agreed.

project/Dependencies.scala Show resolved Hide resolved
@@ -72,7 +75,7 @@ abstract class AkkaSpec(_system: ActorSystem)

def this() = this(ActorSystem(AkkaSpec.getCallerName(getClass), AkkaSpec.testConf))

val log: LoggingAdapter = Logging(system, this.getClass)
val log: LoggingAdapter = Logging(system, this.getClass.asInstanceOf[Class[Any]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried variations but also failed to come up something better. It seems some automatic conversions wrt to Java wildcard types don't work as well (or at least different) in Scala 3 than before.

Copy link
Contributor

@jrudolph jrudolph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, no blockers, if anything, it's the sorry shape of testing in the Scala 3 branch...

Thanks a lot, @hughsimpson, of getting this important milestone in place!

@jrudolph jrudolph changed the title Compile akka-http-core scala3: compile akka-http-core and pass all its tests Apr 11, 2022
@jrudolph jrudolph merged commit 0a979b8 into akka:scala-3 Apr 11, 2022
@jrudolph jrudolph mentioned this pull request Apr 11, 2022
22 tasks
@prolativ
Copy link

@jrudolph @hughsimpson it looks I've found the core reason of the problem with TailSwitch scala/scala3#14903

@jrudolph
Copy link
Contributor

@jrudolph @hughsimpson it looks I've found the core reason of the problem with TailSwitch lampepfl/dotty#14903

Great work. While the current solution works for akka-http, there are probably other parboiled2 parsers where the workaround still wouldn't be enough, so good to make progress on a more general solution!

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

Successfully merging this pull request may close these issues.

4 participants