Skip to content

Compiler crash when defining parameterless PolyFunction #11040

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

Closed
prolativ opened this issue Jan 8, 2021 · 1 comment
Closed

Compiler crash when defining parameterless PolyFunction #11040

prolativ opened this issue Jan 8, 2021 · 1 comment

Comments

@prolativ
Copy link
Contributor

prolativ commented Jan 8, 2021

Minimized code

val foo = new PolyFunction { def apply[A]: Unit = ??? }

Output (click arrow to expand)

exception while typing [cannot display due to assertion failed, raw string = TypeDef(rs$line$1$,Template(DefDef(<init>,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],EmptyTree),List(Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object)]),<init>),List())),ValDef(_,EmptyTree,EmptyTree),List(DefDef(writeReplace,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),type AnyRef)],Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class runtime)),class ModuleSerializationProxy)]),<init>),List(Literal(Constant(TermRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module rs$line$1)))))), DefDef(foo,List(),List(),TypeTree[RefinedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),trait PolyFunction),apply,ExprType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Unit)))],Block(List(TypeDef($anon,Template(DefDef(<init>,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],EmptyTree),List(Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object)]),<init>),List()), TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),trait PolyFunction)]),ValDef(_,EmptyTree,EmptyTree),List(DefDef(apply,List(),List(),TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Unit)],Ident(???)))))),Typed(Apply(Select(New(TypeTree[TypeRef(NoPrefix,class $anon)]),<init>),List()),TypeTree[RefinedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),trait PolyFunction),apply,ExprType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Unit)))]))))))] of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing [cannot display due to assertion failed, raw string = PackageDef(Ident(<empty>),List(ValDef(rs$line$1,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class rs$line$1$)],Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class rs$line$1$)]),<init>),List())), TypeDef(rs$line$1$,Template(DefDef(<init>,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],EmptyTree),List(Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object)]),<init>),List())),ValDef(_,EmptyTree,EmptyTree),List(DefDef(writeReplace,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),type AnyRef)],Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class runtime)),class ModuleSerializationProxy)]),<init>),List(Literal(Constant(TermRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module rs$line$1)))))), DefDef(foo,List(),List(),TypeTree[RefinedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),trait PolyFunction),apply,ExprType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Unit)))],Block(List(TypeDef($anon,Template(DefDef(<init>,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],EmptyTree),List(Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object)]),<init>),List()), TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),trait PolyFunction)]),ValDef(_,EmptyTree,EmptyTree),List(DefDef(apply,List(),List(),TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Unit)],Ident(???)))))),Typed(Apply(Select(New(TypeTree[TypeRef(NoPrefix,class $anon)]),<init>),List()),TypeTree[RefinedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),trait PolyFunction),apply,ExprType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Unit)))]))))))))] of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
	at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$apply(TypeErasure.scala:464)
	at dotty.tools.dotc.core.TypeErasure.eraseResult(TypeErasure.scala:611)
	at dotty.tools.dotc.core.TypeErasure.eraseInfo(TypeErasure.scala:548)
	at dotty.tools.dotc.core.TypeErasure$.transformInfo(TypeErasure.scala:202)
	at dotty.tools.dotc.transform.Erasure.transform(Erasure.scala:83)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:805)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:854)
	at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:122)
	at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:116)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:109)
	at dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:494)
	at dotty.tools.dotc.transform.Erasure$Typer.dropConstructorProxies$$anonfun$1(Erasure.scala:990)
	at dotty.tools.dotc.transform.Erasure$Typer$$Lambda$975/0x00000000638b3a20.applyVoid(Unknown Source)
	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.core.Scopes$Scope.foreach(Scopes.scala:94)
	at dotty.tools.dotc.transform.Erasure$Typer.dropConstructorProxies(Erasure.scala:990)
	at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:994)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2516)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2520)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2589)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2659)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2663)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2685)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2735)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1004)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2313)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2561)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2590)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2659)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2663)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2779)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:124)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:296)
	at dotty.tools.dotc.core.Phases$Phase$$Lambda$677/000000000000000000.apply(Unknown Source)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
	at dotty.tools.dotc.Run$$Lambda$357/000000000000000000.applyVoid(Unknown Source)
	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:195)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
	at dotty.tools.dotc.Run$$Lambda$317/000000000000000000.apply$mcV$sp(Unknown Source)
	at scala.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:210)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:152)
	at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:151)
	at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:161)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:234)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:197)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:133)
	at dotty.tools.repl.ReplDriver$$Lambda$271/0x0000000094829020.apply(Unknown Source)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:152)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:133)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)
@bishabosha
Copy link
Member

I would close this in favour of #10075 which documents some more examples in this comment #10075 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants