From 00a1e6dfc08390493bbfe702333ff341a2e7172e Mon Sep 17 00:00:00 2001 From: Dmitry Karlinsky Date: Sat, 11 Jan 2020 21:05:40 +0200 Subject: [PATCH] Adding test reproducing the compiler crash reported in #7965 --- .../dotty/tools/dotc/CompilationTests.scala | 7 ++++ .../failureToJoinAlternatives.scala | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/compiler-crash/failureToJoinAlternatives.scala diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 8e5cf657a624..3ae09a5f3381 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -284,6 +284,13 @@ class CompilationTests extends ParallelTesting { implicit val testGroup: TestGroup = TestGroup("explicitNullsRun") compileFilesInDir("tests/explicit-nulls/run", explicitNullsOptions) }.checkRuns() + + @Test def compilerCrash: Unit = { + implicit val testGroup: TestGroup = TestGroup("compilePos") + aggregateTests( + compileFilesInDir("tests/compiler-crash", defaultOptions), + ) + }.checkCompile() } object CompilationTests { diff --git a/tests/compiler-crash/failureToJoinAlternatives.scala b/tests/compiler-crash/failureToJoinAlternatives.scala new file mode 100644 index 000000000000..aca7e5108512 --- /dev/null +++ b/tests/compiler-crash/failureToJoinAlternatives.scala @@ -0,0 +1,38 @@ + +class Has[A] + +trait ZLayer[-RIn, +E, +ROut <: Has[_]] { + def >>>[E1 >: E, ROut2 <: Has[_]](that: ZLayer[ROut, E1, ROut2]): ZLayer[RIn, E1, ROut2] + def ++[E1 >: E, RIn2, ROut1 >: ROut <: Has[_], ROut2 <: Has[_]](that: ZLayer[RIn2, E1, ROut2]): ZLayer[RIn with RIn2, E1, ROut1 with ROut2] +} +object ZLayer { + type NoDeps[+E, +B <: Has[_]] = ZLayer[Any, E, B] +} + +type ServiceA = Has[ServiceA.Service] +object ServiceA { + trait Service + val live: ZLayer.NoDeps[Nothing, ServiceA] = ??? +} + +type ServiceB = Has[ServiceB.Service] +object ServiceB { + trait Service + val live: ZLayer.NoDeps[Nothing, ServiceB] = ??? +} + +type ServiceC = Has[ServiceC.Service] +object ServiceC { + trait Service + val live: ZLayer.NoDeps[Nothing, ServiceC] = ??? +} + +type ServiceD = Has[ServiceD.Service] +object ServiceD { + trait Service + val live: ZLayer.NoDeps[ServiceC, ServiceD with ServiceC] = ??? +} + +val combined = + ServiceA.live >>> + (ServiceB.live ++ (ServiceC.live >>> ServiceD.live))