Skip to content

Compiler AssertionError when joining alternatives over intersection types #7965

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

Closed
jdegoes opened this issue Jan 11, 2020 · 5 comments
Closed

Comments

@jdegoes
Copy link

jdegoes commented Jan 11, 2020

minimized code

I have not yet attempted minimization. This is an AssertionError deep in the compiler related to intersection types; no information is available on where the failure occurred.

The bug can currently be reproduced on https://github.com/jdegoes/zio by running:

 ./sbt ++"0.21.0-RC1" testJVMDotty
Compilation output
java.lang.AssertionError: Failure to join alternatives zio.Has[zio.test.Annotations.Service] & zio.Has[zio.block
ing.Blocking.Service] &
   
(zio.Has[zio.clock.Clock.Service] & (
  zio.Has[zio.test.environment.TestClock.Service]
 & zio.Has[zio.scheduler.Scheduler.Service]))
 & (zio.Has[zio.console.Console.Service] & al 0s
  zio.Has[zio.test.environment.TestConsole.Service]
) & zio.Has[zio.test.environment.Live.Service] & (
  zio.Has[zio.random.Random.Service]
 & zio.Has[zio.test.environment.TestRandom.Service]) & 
  zio.Has[zio.test.Sized.Service] and zio.Has[zio.system.System.Service] & 
  zio.Has[zio.test.environment.TestSystem.Service] while compiling /Users/john/Documents/git/scalaz-zio-alpha/test/jvm/src/main/scala/zio/test/ConcurrentHashMap.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/jvm/src/main/scala/zio/test/TestPlatform.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/jvm/src/main/scala/zio/test/environment/PlatformSpecific.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/jvm/src/main/scala/zio/test/reflect/Reflect.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala-dotty/zio/test/AssertionVariants.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala-dotty/zio/test/CompileVariants.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala-dotty/zio/test/TestVersion.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/AbstractRunnableSpec.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Annotations.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Assertion.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/AssertionValue.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/BoolAlgebra.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/BoolAlgebraM.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/DefaultRunnableSpec.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/DefaultTestReporter.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/ExecutionStrategy.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/FailureDetails.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Fun.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/FunctionVariants.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Gen.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/GenFailureDetails.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/GenZIO.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/RenderUtils.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/RunnableSpec.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Sample.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Sized.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Spec.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/Summary.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/SummaryBuilder.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestAnnotation.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestAnnotationMap.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestAnnotationRenderer.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestArgs.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestAspect.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestExecutor.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestFailure.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestLogger.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestRunner.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestSuccess.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TestTimeoutException.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TimeVariants.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/TimeoutVariants.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/environment/Live.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/environment/Restorable.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/environment/TestClock.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/environment/TestConsole.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/environment/TestRandom.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/environment/TestSystem.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/environment/package.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/ArgumentExpectation.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/Expectation.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/Method.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/Mock.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/MockClock.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/MockConsole.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/MockException.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/MockRandom.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/MockSystem.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/Mockable.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/mock/ReturnExpectation.scala, /Users/john/Documents/git/scalaz-zio-alpha/test/shared/src/main/scala/zio/test/package.scala
[error] ## Exception when compiling 61 sources to /Users/john/Documents/git/scalaz-zio-alpha/test/jvm/target/scala-0.21/classes
[error] java.lang.AssertionError: Failure to join alternatives zio.Has[zio.test.Annotations.Service] & zio.Has[z
io.blocking.Blocking.Service] &
[error]    
[error] (zio.Has[zio.clock.Clock.Service] & (
[error]   zio.Has[zio.test.environment.TestClock.Service]
[error]  & zio.Has[zio.scheduler.Scheduler.Service]))
[error]  & (zio.Has[zio.console.Console.Service] & 
[error]   zio.Has[zio.test.environment.TestConsole.Service]
[error] ) & zio.Has[zio.test.environment.Live.Service] & (
[error]   zio.Has[zio.random.Random.Service]
[error]  & zio.Has[zio.test.environment.TestRandom.Service]) & 
[error]   zio.Has[zio.test.Sized.Service] and zio.Has[zio.system.System.Service] & 
[error]   zio.Has[zio.test.environment.TestSystem.Service]
[error] dotty.tools.dotc.core.TypeOps.fail$1(TypeOps.scala:200)
[error] dotty.tools.dotc.core.TypeOps.mergeRefinedOrApplied$1(TypeOps.scala:223)
[error] dotty.tools.dotc.core.TypeOps.baseTp$2$$anonfun$2(TypeOps.scala:310)
[error] dotty.tools.dotc.core.Types$Type.mapReduceOr(Types.scala:404)
[error] dotty.tools.dotc.core.TypeOps.baseTp$3(TypeOps.scala:310)
[error] dotty.tools.dotc.core.TypeOps.approximateOr$2$$anonfun$1(TypeOps.scala:311)
[error] scala.collection.immutable.List.map(List.scala:219)
[error] dotty.tools.dotc.core.TypeOps.approximateOr$1(TypeOps.scala:311)
[error] dotty.tools.dotc.core.TypeOps.orDominator(TypeOps.scala:316)
[error] dotty.tools.dotc.core.Contexts$Context.orDominator(Contexts.scala:75)
[error] dotty.tools.dotc.core.Types$OrType.join(Types.scala:2887)
[error] dotty.tools.dotc.core.Types$Type.widenUnionWithoutNull(Types.scala:1125)
[error] dotty.tools.dotc.core.Types$Type.widenUnion(Types.scala:1119)
[error] dotty.tools.dotc.core.ConstraintHandling.widenOr$1(ConstraintHandling.scala:307)
[error] dotty.tools.dotc.core.ConstraintHandling.widenInferred(ConstraintHandling.scala:316)
[error] dotty.tools.dotc.core.TypeComparer.widenInferred(TypeComparer.scala:30)
[error] dotty.tools.dotc.core.ConstraintHandling.instanceType(ConstraintHandling.scala:328)
[error] dotty.tools.dotc.core.TypeComparer.instanceType(TypeComparer.scala:30)
[error] dotty.tools.dotc.core.Types$TypeVar.instantiate(Types.scala:3927)
[error] dotty.tools.dotc.typer.Inferencing.doInstantiate$1(Inferencing.scala:484)
[error] dotty.tools.dotc.typer.Inferencing.interpolateTypeVars(Inferencing.scala:487)
[error] dotty.tools.dotc.typer.Typer.interpolateTypeVars(Typer.scala:83)
[error] dotty.tools.dotc.typer.Typer.simplify(Typer.scala:2191)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2179)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2162)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2177)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2333)
[error] dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:478)
[error] dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:502)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2099)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2333)
[error] dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:1588)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2103)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2247)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2291)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1784)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2109)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2247)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2291)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1910)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2150)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2177)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2333)
[error] dotty.tools.dotc.typer.FrontEnd.liftedTree1$2(FrontEnd.scala:78)
[error] dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:83)
[error] dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:42)
[error] dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:84)
[error] dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:114)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:305)
[error] dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:114)
[error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$5(Run.scala:171)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179)
[error] dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:186)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:123)
[error] dotty.tools.dotc.Run.compile(Run.scala:106)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
[error] dotty.tools.dotc.Driver.process(Driver.scala:189)
[error] dotty.tools.dotc.Main.process(Main.scala)
[error] xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
[error] xsbt.CompilerInterface.run(CompilerInterface.java:41)
[error] sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] java.lang.reflect.Method.invoke(Method.java:498)
[error] sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scal
a:343)
[error] sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
[error] sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
[error] sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
[error] sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
[error] sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
[error] sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
[error] sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:3
01)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:1762)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:1735)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] sbt.Execute.work(Execute.scala:290)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] java.lang.Thread.run(Thread.java:748)
[error]            
[error] java.lang.AssertionError: Failure to join alternatives zio.Has[zio.test.Annotations.Service] & zio.Has[z
io.blocking.Blocking.Service] &
[error]    
[error] (zio.Has[zio.clock.Clock.Service] & (
[error]   zio.Has[zio.test.environment.TestClock.Service]
[error]  & zio.Has[zio.scheduler.Scheduler.Service]))
[error]  & (zio.Has[zio.console.Console.Service] & 
[error]   zio.Has[zio.test.environment.TestConsole.Service]
[error] ) & zio.Has[zio.test.environment.Live.Service] & (
[error]   zio.Has[zio.random.Random.Service]
[error]  & zio.Has[zio.test.environment.TestRandom.Service]) & 
[error]   zio.Has[zio.test.Sized.Service] and zio.Has[zio.system.System.Service] & 
[error]   zio.Has[zio.test.environment.TestSystem.Service]
[error]         at dotty.tools.dotc.core.TypeOps.fail$1(TypeOps.scala:200)
[error]         at dotty.tools.dotc.core.TypeOps.mergeRefinedOrApplied$1(TypeOps.scala:223)
[error]         at dotty.tools.dotc.core.TypeOps.baseTp$2$$anonfun$2(TypeOps.scala:310)
[error]         at dotty.tools.dotc.core.Types$Type.mapReduceOr(Types.scala:404)
[error]         at dotty.tools.dotc.core.TypeOps.baseTp$3(TypeOps.scala:310)
[error]         at dotty.tools.dotc.core.TypeOps.approximateOr$2$$anonfun$1(TypeOps.scala:311)
[error]         at scala.collection.immutable.List.map(List.scala:219)
[error]         at dotty.tools.dotc.core.TypeOps.approximateOr$1(TypeOps.scala:311)
[error]         at dotty.tools.dotc.core.TypeOps.orDominator(TypeOps.scala:316)
[error]         at dotty.tools.dotc.core.Contexts$Context.orDominator(Contexts.scala:75)
[error]         at dotty.tools.dotc.core.Types$OrType.join(Types.scala:2887)
[error]         at dotty.tools.dotc.core.Types$Type.widenUnionWithoutNull(Types.scala:1125)
[error]         at dotty.tools.dotc.core.Types$Type.widenUnion(Types.scala:1119)
[error]         at dotty.tools.dotc.core.ConstraintHandling.widenOr$1(ConstraintHandling.scala:307)
[error]         at dotty.tools.dotc.core.ConstraintHandling.widenInferred(ConstraintHandling.scala:316)
[error]         at dotty.tools.dotc.core.TypeComparer.widenInferred(TypeComparer.scala:30)
[error]         at dotty.tools.dotc.core.ConstraintHandling.instanceType(ConstraintHandling.scala:328)
[error]         at dotty.tools.dotc.core.TypeComparer.instanceType(TypeComparer.scala:30)
[error]         at dotty.tools.dotc.core.Types$TypeVar.instantiate(Types.scala:3927)
[error]         at dotty.tools.dotc.typer.Inferencing.doInstantiate$1(Inferencing.scala:484)
[error]         at dotty.tools.dotc.typer.Inferencing.interpolateTypeVars(Inferencing.scala:487)
[error]         at dotty.tools.dotc.typer.Typer.interpolateTypeVars(Typer.scala:83)
[error]         at dotty.tools.dotc.typer.Typer.simplify(Typer.scala:2191)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2179)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2162)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2177)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error]         at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2333)
[error]         at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:478)
[error]         at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:502)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2099)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error]         at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2333)
[error]         at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:1588)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2103)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error]         at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2247)
[error]         at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2291)
[error]         at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1784)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2109)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2176)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error]         at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2247)
[error]         at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2291)
[error]         at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1910)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2150)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2177)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2213)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2225)
[error]         at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2333)
[error]         at dotty.tools.dotc.typer.FrontEnd.liftedTree1$2(FrontEnd.scala:78)
[error]         at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:83)
[error]         at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:42)
[error]         at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:84)
[error]         at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:114)
[error]         at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:305)
[error]         at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:114)
[error]         at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161)
[error]         at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error]         at dotty.tools.dotc.Run.runPhases$5(Run.scala:171)
[error]         at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179)
[error]         at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
[error]         at dotty.tools.dotc.Run.compileUnits(Run.scala:186)
[error]         at dotty.tools.dotc.Run.compileSources(Run.scala:123)
[error]         at dotty.tools.dotc.Run.compile(Run.scala:106)
[error]         at dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
[error]         at dotty.tools.dotc.Driver.process(Driver.scala:189)
[error]         at dotty.tools.dotc.Main.process(Main.scala)
[error]         at xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
[error]         at xsbt.CompilerInterface.run(CompilerInterface.java:41)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.lang.reflect.Method.invoke(Method.java:498)
[error]         at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
[error]         at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
[error]         at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
[error]         at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
[error]         at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
[error]         at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
[error]         at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
[error]         at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
[error]         at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
[error]         at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
[error]         at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
[error]         at sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
[error]         at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
[error]         at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
[error]         at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:1762)
[error]         at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:1735)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error]         at sbt.Execute.work(Execute.scala:290)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] (testJVM / Compile / compileIncremental) java.lang.AssertionError: Failure to join alternatives zio.Has[zio.test.Annotations.Service] & zio.Has[zio.blocking.Blocking.Service] &
[error]    
[error] (zio.Has[zio.clock.Clock.Service] & (
[error]   zio.Has[zio.test.environment.TestClock.Service]
[error]  & zio.Has[zio.scheduler.Scheduler.Service]))
[error]  & (zio.Has[zio.console.Console.Service] & 
[error]   zio.Has[zio.test.environment.TestConsole.Service]
[error] ) & zio.Has[zio.test.environment.Live.Service] & (
[error]   zio.Has[zio.random.Random.Service]
[error]  & zio.Has[zio.test.environment.TestRandom.Service]) & 
[error]   zio.Has[zio.test.Sized.Service] and zio.Has[zio.system.System.Service] & 
[error]   zio.Has[zio.test.environment.TestSystem.Service]
[error] Total time: 6 s, completed Jan 11, 2020 6:58:39 AM

expectation

I expect this code to compile in Dotty, as it does in Scala 2.11, 2.12, and 2.13.

@bishabosha bishabosha added itype:crash stat:needs minimization Needs a self contained minimization labels Jan 11, 2020
@dkarlinsky
Copy link

I was able to reproduce this issue (both on 0.21.x branch and on master) with the following code:

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))

I this would help, I can create a PR adding a reproducing test to dotty.tools.dotc.CompilationTests

dkarlinsky added a commit to dkarlinsky/dotty that referenced this issue Jan 11, 2020
@bishabosha bishabosha removed the stat:needs minimization Needs a self contained minimization label Jan 11, 2020
@odersky odersky self-assigned this Jan 13, 2020
@smarter
Copy link
Member

smarter commented Jan 13, 2020

Thanks for the minimization! I've minimized it further to:

class Has[A]
trait X
trait Y
trait Z

class Test {
  val x: Has[X] | (Has[Y] & Has[Z])
  def foo[T <: Has[_]](has: T): T = has
  foo(x)
}

odersky added a commit to dotty-staging/dotty that referenced this issue Jan 15, 2020
Allow that the base type of a join may be a conjunction.
smarter added a commit that referenced this issue Jan 15, 2020
@adamgfraser
Copy link
Contributor

@odersky Thanks for your work on this! I will update to the latest nightly tomorrow and report back.

@jdegoes
Copy link
Author

jdegoes commented Jan 16, 2020

@odersky Thanks for the prompt fix!

@adamgfraser
Copy link
Contributor

Just wanted to follow up on this. Sorry for the delay, got slowed down a little bit with the issue with publishing nightlies. With this change we were able to resolve the issue and restore Dotty support. However, we are seeing some type inference regression in Dotty versus Scala 2 here that I will open another ticket for momentarily. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants