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 failed when not adding prefix to extension method in method body #11318

Closed
Katrix opened this issue Feb 4, 2021 · 3 comments · Fixed by #11882
Closed

Assertion failed when not adding prefix to extension method in method body #11318

Katrix opened this issue Feb 4, 2021 · 3 comments · Fixed by #11882

Comments

@Katrix
Copy link
Contributor

Katrix commented Feb 4, 2021

Compiler version

3.0.0-M4-bin-20210204-406ff9d-NIGHTLY

Minimized code

trait RepresentableK[F[_[_], _]]:
  type RepresentationK[_]

  def tabulateK[A[_], C](f: RepresentationK ~>: A): F[A, C]

  extension[A[_], C](fa: F[A, C])
    def indexK: RepresentationK ~>: A
  
    def mapK[B[_]] (f: A ~>: B): F[B, C] =
      tabulateK([Z] => (r: RepresentationK[Z]) => f(indexK(r)))

Replacing f(indexK(r)) with f(fa.indexK(r))
I honestly didn't expect it to work, but I more just expected a normal error message.

Output (click arrow to expand)

[error] ## Exception when compiling 15 sources to D:\DevProjects\Stable\perspective\dotty\perspective\target\scala-3.0.0-M4\classes
[error] java.lang.AssertionError: assertion failed
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.extensionParam(SymDenotations.scala:341)
[error] dotty.tools.dotc.typer.Typer.isLocalExtensionMethodRef$3$$anonfun$2(Typer.scala:513)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.hasAltWith(Denotations.scala:610)
[error] dotty.tools.dotc.typer.Typer.isLocalExtensionMethodRef$1(Typer.scala:513)
[error] dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:519)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2546)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2638)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2824)
[error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:821)
[error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:974)
[error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:301)
[error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:102)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2577)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2639)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$2(ProtoTypes.scala:414)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:370)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:415)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:789)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:789)
[error] dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:520)
[error] dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:580)
[error] dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:431)
[error] dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:684)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:788)
[error] dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:999)
[error] dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:301)
[error] dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:102)
[error] dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:846)
[error] dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:925)
[error] dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2832)
[error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:936)
[error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:974)
[error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:301)
[error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:102)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2577)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2639)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1305)
[error] dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1292)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1305)
[error] dotty.tools.dotc.typer.Namer.rhsType$1$$anonfun$1(Namer.scala:1447)
[error] dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:223)
[error] dotty.tools.dotc.typer.Namer.rhsType$2(Namer.scala:1447)
[error] dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1458)
[error] dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1459)
[error] dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1470)
[error] dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1479)
[error] dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1562)
[error] dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:703)
[error] dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:830)
[error] dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:731)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
[error] dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
[error] dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
[error] dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2519)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2544)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2638)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2730)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2780)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2227)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2565)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2569)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2638)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2730)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2780)
[error] dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:969)
[error] dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:973)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2585)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2639)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.typedNew(Typer.scala:735)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2581)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2639)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2623)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2639)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$2(ProtoTypes.scala:414)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:370)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:415)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:789)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:789)
[error] dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:520)
[error] dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:580)
[error] dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:431)
[error] dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:684)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:788)
[error] dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:999)
[error] dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:301)
[error] dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:102)
[error] dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:846)
[error] dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:925)
[error] dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2832)
[error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:936)
[error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:974)
[error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:301)
[error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:102)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2577)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2639)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2824)
[error] dotty.tools.dotc.typer.Typer.$anonfun$35(Typer.scala:2081)
[error] dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:223)
[error] dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2081)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2554)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2638)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2730)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2780)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2227)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2565)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2569)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2638)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2730)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2780)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2362)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2610)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2639)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2704)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2708)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2824)
[error] dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
[error] dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
[error] dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:43)
[error] dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
[error] dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:120)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:120)
[error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:189)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.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:199)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:207)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:214)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:150)
[error] dotty.tools.dotc.Run.compile(Run.scala:134)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:92)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:186)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:176)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:157)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:157)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:573)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:573)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:173)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:171)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:458)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:413)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:498)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:400)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:165)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:573)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:491)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2176)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2133)
[error] sbt.internal.io.Retry$.apply(Retry.scala:40)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2129)
[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:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[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)
@prolativ
Copy link
Contributor

prolativ commented Feb 4, 2021

@Katrix as a rule when supplying minimized code to an issue please first try compiling it in separation from the codebase of your project so that missing definitions don't hide the actual error that we'll need to reproduce.
In this case ~>: is not defined although I guess it should be something like

trait ~>: [A[_], B[_]]

@Katrix
Copy link
Contributor Author

Katrix commented Feb 4, 2021

Ahh yes, sorry about that. Guess I forgot about the arrow. Generally minimize code in Scastie, but that wasn't an option here as I used the nightly version.

type FunctionK[A[_], B[_]] = [Z] => A[Z] => B[Z]
type ~>:[A[_], B[_]] = FunctionK[A, B]

anatoliykmetyuk added a commit to dotty-staging/dotty that referenced this issue Mar 24, 2021
@anatoliykmetyuk
Copy link
Contributor

Minimised:

extension(a: Int)
  def b: Int = ???
  def h: Unit =
    [A] => (r: Int) => b

@anatoliykmetyuk anatoliykmetyuk linked a pull request Mar 24, 2021 that will close this issue
anatoliykmetyuk added a commit to dotty-staging/dotty that referenced this issue Jul 16, 2021
smarter added a commit that referenced this issue Jul 16, 2021
BarkingBad pushed a commit to BarkingBad/dotty that referenced this issue Jul 23, 2021
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.

3 participants