Skip to content

Assertion in TypeErasure.sigName when signature references type coming from self-type #3083

Closed
@esarbe

Description

@esarbe
object Main {

  trait Literal {
    type F[T]
    def num(i: Int): F[Int]
  }

  trait Addition { self: Literal =>
    def add(l: F[Int], r: F[Int]): F[Int]
  }

  def expression(adder: Addition) = {
    import adder._
    add(num(1), num(2))
  }
}

will result in [error] (compile:compileIncremental) java.lang.AssertionError: assertion failed: NoType

Stacktrace:

> compile
[info] Compiling 1 Scala source to /home/raphael/source/final-tagless-encoding/target/scala-0.4/classes...
no sig for NoType because of ()
java.lang.AssertionError: assertion failed: NoType
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$sigName(TypeErasure.scala:555)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$sigName(TypeErasure.scala:535)
	at dotty.tools.dotc.core.TypeErasure$.sigName(TypeErasure.scala:142)
	at dotty.tools.dotc.core.Signature$.apply(Signature.scala:117)
	at dotty.tools.dotc.core.Types$MethodicType.resultSignature(Types.scala:2473)
	at dotty.tools.dotc.core.Types$MethodType.computeSignature(Types.scala:2715)
	at dotty.tools.dotc.core.Types$MethodicType.signature(Types.scala:2483)
	at dotty.tools.dotc.core.Types$MethodOrPoly.signature(Types.scala:2590)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:607)
	at dotty.tools.dotc.core.Types$NamedType.withDenot(Types.scala:1655)
	at dotty.tools.dotc.core.Types$TermRef$.apply(Types.scala:2035)
	at dotty.tools.dotc.core.Types$Type.select(Types.scala:1125)
	at dotty.tools.dotc.typer.Typer.selection$1(Typer.scala:180)
	at dotty.tools.dotc.typer.Typer.wildImportRef$1(Typer.scala:221)
	at dotty.tools.dotc.typer.Typer.loop$2(Typer.scala:312)
	at dotty.tools.dotc.typer.Typer.findRef$1(Typer.scala:331)
	at dotty.tools.dotc.typer.Typer.op$79(Typer.scala:350)
	at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:99)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1612)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1678)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1694)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1751)
	at dotty.tools.dotc.typer.Applications.op$21(Applications.scala:676)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:674)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:774)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1632)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1694)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1751)
	at dotty.tools.dotc.typer.Typer.op$58(Typer.scala:630)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:622)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1639)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1694)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:945)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:935)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:945)
	at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1063)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1064)
	at dotty.tools.dotc.typer.Namer.lhsType$lzyINIT1$1(Namer.scala:1065)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1065)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1082)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1090)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1156)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:737)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:782)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:760)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:228)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:206)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:345)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1585)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1610)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1678)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1694)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1716)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1739)
	at dotty.tools.dotc.typer.Typer.op$15(Typer.scala:1405)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1335)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1623)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1678)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1694)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1716)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1739)
	at dotty.tools.dotc.typer.Typer.op$12(Typer.scala:1522)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1509)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1662)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1694)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1751)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:64)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:32)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:68)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:93)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:93)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$3$$anonfun$2(Run.scala:123)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:131)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:136)
	at dotty.tools.dotc.Run.compileSources(Run.scala:95)
	at dotty.tools.dotc.Run.compile(Run.scala:79)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
	at dotty.tools.dotc.Driver.process(Driver.scala:124)
	at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:63)
	at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:53)
	at xsbt.CompilerInterface.run(CompilerInterface.scala:37)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:107)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:53)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
	at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply$mcV$sp(MixedAnalyzingCompiler.scala:50)
	at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
	at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
	at sbt.compiler.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:74)
	at sbt.compiler.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:49)
	at sbt.compiler.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:64)
	at sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
	at sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:66)
	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:64)
	at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:32)
	at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:72)
	at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:71)
	at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:99)
	at sbt.inc.Incremental$.compile(Incremental.scala:71)
	at sbt.inc.IncrementalCompile$.apply(Compile.scala:54)
	at sbt.compiler.IC$.compileInternal(IncrementalCompiler.scala:160)
	at sbt.compiler.IC$.incrementalCompile(IncrementalCompiler.scala:138)
	at sbt.Compiler$.compile(Compiler.scala:155)
	at sbt.Compiler$.compile(Compiler.scala:141)
	at sbt.Defaults$.sbt$Defaults$$compileIncrementalTaskImpl(Defaults.scala:886)
	at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:877)
	at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:875)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
no sig for HKApply(TypeRef(TermRef(NoPrefix,adder),F),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),scala)/withSig(Signature(List(),)),Int))) because of ()
failure while taking result signature of (l: adder.F[Int], r: adder.F[Int]): adder.F[Int]: adder.F[Int]
[info] 
[info] cannot take signature of (l: adder.F[Int], r: adder.F[Int]): adder.F[Int]
[info] 
[info] exception occurred while typechecking /home/raphael/source/final-tagless-encoding/src/main/scala/Main.scala
[info] 
[info] exception occurred while compiling /home/raphael/source/final-tagless-encoding/src/main/scala/Main.scala
[trace] Stack trace suppressed: run last compile:compileIncremental for the full output.
[error] (compile:compileIncremental) java.lang.AssertionError: assertion failed: NoType
[error] Total time: 1 s, completed Sep 6, 2017 11:28:30 PM

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