Skip to content

Polymorphic functions crashes compiler with CC enabled #16871

Closed
@natsukagami

Description

@natsukagami

Compiler version

If you're not sure what version you're using, run print scalaVersion from sbt
(if you're running scalac manually, use scalac -version instead).

Latest main branch.

Minimized code

import scala.language.experimental.captureChecking

val f: [X] => Int => Int = [X] => x => x

Output

exception occurred while typechecking Test.scala
exception occurred while compiling Test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: illegal flagset combination: <param> <synthetic> and <{*}> while compiling Test.scala
java.lang.AssertionError: assertion failed: illegal flagset combination: <param> <synthetic> and <{*}>
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.Flags$.$bar(Flags.scala:40)
	at dotty.tools.dotc.ast.untpd$Modifiers.$bar(untpd.scala:245)
	at dotty.tools.dotc.ast.Trees$DefTree.withAddedFlags(Trees.scala:303)
	at dotty.tools.dotc.ast.Trees$DefTree.withAddedFlags$(Trees.scala:286)
	at dotty.tools.dotc.ast.Trees$NamedDefTree.withAddedFlags(Trees.scala:357)
	at dotty.tools.dotc.ast.desugar$.$anonfun$54(Desugar.scala:1735)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.ast.desugar$.makePolyFunction$1(Desugar.scala:1736)
	at dotty.tools.dotc.ast.desugar$.apply(Desugar.scala:1784)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2997)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3080)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3084)
	at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3199)
	at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1616)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1609)
	at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1616)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1704)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:783)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:922)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:810)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:390)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2891)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2916)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3012)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3080)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3084)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3196)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1619)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1609)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1619)
	at dotty.tools.dotc.typer.Namer.completeParams$$anonfun$1(Namer.scala:1633)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.typer.Namer.completeParams(Namer.scala:1633)
	at dotty.tools.dotc.typer.Namer.defDefSig$$anonfun$3(Namer.scala:1744)
	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.typer.Namer.defDefSig(Namer.scala:1744)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:787)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:922)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:810)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:390)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2891)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2916)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3012)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3080)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3084)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3106)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3152)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2584)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2938)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2942)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3012)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3080)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3084)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3106)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3152)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2714)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2983)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3080)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3084)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3196)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54)
	at scala.Function0.apply$mcV$sp(Function0.scala:42)
	at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:437)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54)
	at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88)
	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.typer.TyperPhase.runOn(TyperPhase.scala:88)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247)
	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:1321)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:263)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:280)
	at dotty.tools.dotc.Run.compileSources(Run.scala:195)
	at dotty.tools.dotc.Run.compile(Run.scala:179)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:195)
	at dotty.tools.dotc.Driver.process(Driver.scala:163)
	at dotty.tools.dotc.Driver.process(Driver.scala:175)
	at dotty.tools.dotc.Driver.main(Driver.scala:205)
	at dotty.tools.dotc.Main.main(Main.scala)

Expectation

Should compile.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions