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

Assertion in Erasure.adaptToType #15738

Closed
scf37 opened this issue Jul 23, 2022 · 4 comments · Fixed by #15742
Closed

Assertion in Erasure.adaptToType #15738

scf37 opened this issue Jul 23, 2022 · 4 comments · Fixed by #15742

Comments

@scf37
Copy link

scf37 commented Jul 23, 2022

Compiler version

3.1.3

Minimized code

object Test {
  trait Transaction
  type Transactional[T] = (t: Transaction) ?=> T

  def ff(x: Int): Transactional[Int] = {
    summon[Transaction]
    x
  }

  def fff(x: Int): Transactional[Int] = {
    summon[Transaction]
    ff(x)
    ???
  }

}

Output (click arrow to expand)

java.lang.AssertionError: assertion failed
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
	at dotty.tools.dotc.transform.Erasure$Boxing$.adaptToType(Erasure.scala:388)
	at dotty.tools.dotc.transform.Erasure$Typer.adapt(Erasure.scala:1053)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2960)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2964)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3036)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1041)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1067)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1071)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2840)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2895)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2960)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2964)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3080)
	at dotty.tools.dotc.typer.Typer.$anonfun$47(Typer.scala:2278)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2278)
	at dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:943)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2808)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2894)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2960)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2964)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2986)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3036)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1041)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2476)
	at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1031)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2820)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2824)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2894)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2960)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2964)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2986)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3036)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1041)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2603)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2865)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2895)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2960)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2964)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3080)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:144)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:311)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:312)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:225)
	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:1328)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:236)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:244)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:253)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:253)
	at dotty.tools.dotc.Run.compileSources(Run.scala:186)
	at dotty.tools.dotc.Run.compile(Run.scala:170)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
	at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
	at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:57)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.doCompile(LocalServer.scala:52)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:30)
	at org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:207)
	at org.jetbrains.jps.incremental.scala.remote.Main$.$anonfun$handleCommand$1(Main.scala:190)
	at org.jetbrains.jps.incremental.scala.remote.Main$.decorated$1(Main.scala:180)
	at org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:187)
	at org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:163)
	at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:103)
	at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
	at jdk.internal.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)

@scf37 scf37 added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 23, 2022
@scf37
Copy link
Author

scf37 commented Jul 23, 2022

Also fails:

  def fff(x: Int): Transactional[Int] = {
    ff(x)
    42
  }

Also:

  def fff(x: Int): Transactional[Int] = {
    ff(x)  
   // Found:    Test.Transactional[Int]
   //Required: Int
   // ff(x)
  }

@scf37
Copy link
Author

scf37 commented Jul 23, 2022

This is regression, worked in 3.1.1, fails since 3.1.2

@odersky
Copy link
Contributor

odersky commented Jul 23, 2022

I note it works if we write type Transactional[T] = Transaction ?=> T. It's the dependent function type (t: Transaction) ?=> T that makes it fail.

@scf37
Copy link
Author

scf37 commented Jul 23, 2022

Actually i've seen it as "finally Scala supports readable function types" :-)

odersky added a commit to dotty-staging/dotty that referenced this issue Jul 24, 2022
@szymon-rd szymon-rd added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 25, 2022
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants