Skip to content

Exception occurred while typechecking summon in nested flatMap #13497

Closed
@armanbilge

Description

@armanbilge

Compiler version

Scala compiler version 3.0.2 -- Copyright 2002-2021, LAMP/EPFL

Minimized code

trait Foo
trait Bar
object Foo:
  given (using Bar): Foo = ???

object Bug:
  def demonstrate: Unit =
    Option.empty[Unit].flatMap { _ =>
      Option.empty[Unit].map { _ =>
        val foo = summon[Foo]
        Option.empty[Unit]
      }
    }

Output (click arrow to expand)

exception occurred while typechecking bug.scala
exception occurred while compiling bug.scala
java.lang.AssertionError: assertion failed: Inconsistent state in TS[20X, 13, 1, 0]: it owns TypeVar(TypeParamRef(A)) whose owningState is TS[13, 1, 0] while compiling bug.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Inconsistent state in TS[20X, 13, 1, 0]: it owns TypeVar(TypeParamRef(A)) whose owningState is TS[13, 1, 0]
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.TyperState.gc$$anonfun$1(TyperState.scala:220)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.util.SimpleIdentitySet$Set1.foreach(SimpleIdentitySet.scala:69)
        at dotty.tools.dotc.core.TyperState.gc(TyperState.scala:226)
        at dotty.tools.dotc.core.TyperState.commit(TyperState.scala:163)
        at dotty.tools.dotc.typer.Inferencing$.isFullyDefined(Inferencing.scala:40)
        at dotty.tools.dotc.typer.Implicits.ignoredInstanceNormalImport$1(Implicits.scala:881)
        at dotty.tools.dotc.typer.Implicits.$anonfun$1(Implicits.scala:896)
        at dotty.tools.dotc.typer.ImplicitSearchError.hiddenImplicitsAddendum(ErrorReporting.scala:419)
        at dotty.tools.dotc.typer.ImplicitSearchError.missingArgMsg(ErrorReporting.scala:267)
        at dotty.tools.dotc.typer.Implicits.missingArgMsg(Implicits.scala:897)
        at dotty.tools.dotc.typer.Implicits.missingArgMsg$(Implicits.scala:774)
        at dotty.tools.dotc.typer.Typer.missingArgMsg(Typer.scala:106)
        at dotty.tools.dotc.typer.Typer.issueErrors$1$$anonfun$1$$anonfun$1(Typer.scala:3353)
        at dotty.tools.dotc.reporting.NoExplanation.msg(Message.scala:132)
        at dotty.tools.dotc.reporting.Message.message(Message.scala:87)
        at dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:99)
        at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:16)
        at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden$(HideNonSensicalMessages.scala:10)
        at dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8)
        at dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:148)
        at dotty.tools.dotc.reporting.Reporter.flush$$anonfun$1(Reporter.scala:206)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.reporting.Reporter.flush(Reporter.scala:206)
        at dotty.tools.dotc.core.TyperState.commit(TyperState.scala:143)
        at dotty.tools.dotc.typer.Applications.fail$1(Applications.scala:986)
        at dotty.tools.dotc.typer.Applications.realApply$7$$anonfun$6$$anonfun$2(Applications.scala:992)
        at scala.Option.getOrElse(Option.scala:201)
        at dotty.tools.dotc.typer.Applications.realApply$8$$anonfun$7(Applications.scala:993)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2952)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:994)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1032)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:317)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:106)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2693)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2941)
        at dotty.tools.dotc.typer.Typer.$anonfun$34(Typer.scala:2156)
        at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2156)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2670)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2755)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2847)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2897)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2352)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2681)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2685)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2755)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2847)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2897)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2475)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2726)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2941)
        at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
        at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:43)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
        at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:120)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:120)
        at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$5(Run.scala:216)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:224)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:231)
        at dotty.tools.dotc.Run.compileSources(Run.scala:166)
        at dotty.tools.dotc.Run.compile(Run.scala:150)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
        at dotty.tools.dotc.Driver.process(Driver.scala:199)
        at dotty.tools.dotc.Driver.process(Driver.scala:167)
        at dotty.tools.dotc.Driver.process(Driver.scala:179)
        at dotty.tools.dotc.Driver.main(Driver.scala:209)
        at dotty.tools.dotc.Main.main(Main.scala)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at coursier.bootstrap.launcher.a.a(Unknown Source)
        at coursier.bootstrap.launcher.Launcher.main(Unknown Source)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions