Skip to content

crash when call method on singleton type pattern #9224

Closed
@bishabosha

Description

@bishabosha

Minimized code

object foo { def test = 23 }

def bar(x: Any) = x match { case m: foo.type => m.test } // need to call m.test

Output (click arrow to expand)

exception occurred while typechecking foo.scala
exception occurred while compiling foo.scala
java.lang.AssertionError: assertion failed: leak: (m : example.type) in {
  m.test:(m.test : => Int)
} while compiling sandbox/foo.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: leak: (m : example.type) in {
  m.test:(m.test : => Int)
}
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.dotc.typer.Typer.ensureNoLocalRefs(Typer.scala:897)
	at dotty.tools.dotc.typer.Typer.caseRest$1(Typer.scala:1407)
	at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:1416)
	at dotty.tools.dotc.typer.Typer.typedCases$$anonfun$1(Typer.scala:1353)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:63)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:79)
	at dotty.tools.dotc.typer.Typer.typedCases(Typer.scala:1355)
	at dotty.tools.dotc.typer.Typer.$anonfun$18(Typer.scala:1345)
	at dotty.tools.dotc.typer.Applications.harmonic(Applications.scala:2069)
	at dotty.tools.dotc.typer.Typer.harmonic(Typer.scala:89)
	at dotty.tools.dotc.typer.Typer.typedMatchFinish(Typer.scala:1345)
	at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:1310)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2410)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2457)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2523)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2532)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2535)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1354)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1344)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1354)
	at dotty.tools.dotc.typer.Namer.rhsType$2(Namer.scala:1485)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1496)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1497)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1508)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1516)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1601)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:816)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:933)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:844)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:259)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:446)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2339)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2364)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2456)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2523)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2532)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2535)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2557)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2602)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2055)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2385)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2389)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2456)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2523)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2532)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2535)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2557)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2602)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2181)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2429)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2457)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2523)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2532)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2535)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2646)
	at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:42)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:114)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:114)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:180)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.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:190)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:198)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:205)
	at dotty.tools.dotc.Run.compileSources(Run.scala:142)
	at dotty.tools.dotc.Run.compile(Run.scala:124)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
	at dotty.tools.dotc.Driver.process(Driver.scala:194)
	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:202)
	at dotty.tools.dotc.Main.main(Main.scala)

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