You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hint: when I comment out the reversed method, everything compiles just fine
objectImplementing_Tuples:sealedtraitTupcaseclassConsTup[T, H<:Tup](head: T, tail: H) extendsTupcaseobjectEmptyTupextendsTupval*:=ConsTup// for unapplytype*:[H, T<:Tup] =ConsTup[H, T] // for type matchingtypeEmptyTup=EmptyTup.type// for type matchingextension [H](head: H)
def*:[T<:Tup](tail: T) =ConsTup(head, tail)
typeFold[T<:Tup, Seed, F[_,_]] =TmatchcaseEmptyTup=>Seedcase h *: t =>Fold[t, F[Seed, h], F]
extension [T<:Tup](v: T)
deffold[Seed, F[_,_]](seed: Seed)(
fn: [C, Acc] => (C, Acc) =>F[C, Acc]
):Fold[T, Seed, F] =
(v matchcaseEmptyTup=> seed
case h *: t => t.fold(fn(h, seed))(fn)
).asInstanceOf[Fold[T, Seed, F]]
extension [T<:Tup](v: T) defreversed=
v.fold[EmptyTup, [C, Acc] =>>Accmatch {
case h *: t =>C*: h *: t
}](EmptyTup)(
[C, Acc] => (c: C, acc: Acc) => acc matchcase _@(_ *: _) => c *: acc
)
@main deftestProperFold=valt= (1*:'2'*:"foo"*:EmptyTup)
valreversed: (String*:Char*:Int*:EmptyTup) = t.reversed
println(reversed)
endImplementing_Tuples
Output (click arrow to expand)
Heavily cropped because the stack trace is quite large
java.lang.AssertionError: assertion failed
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.extensionParam(SymDenotations.scala:341)
at dotty.tools.dotc.typer.Typer.isLocalExtensionMethodRef$3$$anonfun$2(Typer.scala:524)
at dotty.tools.dotc.core.Denotations$SingleDenotation.hasAltWith(Denotations.scala:637)
at dotty.tools.dotc.core.Denotations$MultiDenotation.hasAltWith(Denotations.scala:1251)
at dotty.tools.dotc.typer.Typer.isLocalExtensionMethodRef$1(Typer.scala:524)
at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:530)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2664)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2757)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2943)
at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:609)
at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:659)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2665)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2757)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2943)
at dotty.tools.dotc.typer.Applications.tryWithProto$1(Applications.scala:1256)
........
The text was updated successfully, but these errors were encountered:
Compiler version
3.0.1
Minimized code
Hint: when I comment out the
reversed
method, everything compiles just fineOutput (click arrow to expand)
Heavily cropped because the stack trace is quite large
The text was updated successfully, but these errors were encountered: