Skip to content

CC: Crash when a Method's Capture Variable and Parameter are Identically Named #25025

@bracevac

Description

@bracevac

Compiler version

Current nightly 3.8.2-RC1-bin-20260120-e277a73-NIGHTLY-git-e277a73

Minimized code

Try one of these

def foo[c^](c: AnyRef^): AnyRef^{c} = c
def foo[c^](c: AnyRef^): Int = 0

Output (click arrow to expand)

We get

Exception in thread "main" java.lang.AssertionError: NoDenotation.owner

Judging by the stack trace, it tries to construct an error message
(so it is correctly identified as an error, good!) but crashes
while doing that:

Details
Exception in thread "main" java.lang.AssertionError: NoDenotation.owner
	at dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2672)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.effectiveOwner(SymDenotations.scala:1190)
	at dotty.tools.dotc.reporting.AlreadyDefined.where$1(messages.scala:2125)
	at dotty.tools.dotc.reporting.AlreadyDefined.msg(messages.scala:2153)
	at dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:426)
	at dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:422)
	at dotty.tools.dotc.reporting.Message.message(Message.scala:426)
	at dotty.tools.dotc.reporting.MessageRendering.messageAndPos(MessageRendering.scala:301)
	at dotty.tools.dotc.reporting.MessageRendering.messageAndPos$(MessageRendering.scala:21)
	at dotty.tools.dotc.reporting.AbstractReporter.messageAndPos(AbstractReporter.scala:8)
	at dotty.tools.dotc.reporting.ConsoleReporter$AbstractConsoleReporter.doReport(ConsoleReporter.scala:43)
	at dotty.tools.repl.ReplDriver.printDiagnostic(ReplDriver.scala:700)
	at dotty.tools.repl.ReplDriver.displayErrors$$anonfun$1(ReplDriver.scala:684)
	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:327)
	at dotty.tools.repl.ReplDriver.displayErrors(ReplDriver.scala:684)
	at dotty.tools.repl.ReplDriver.compile$$anonfun$1(ReplDriver.scala:383)
	at scala.util.Either.fold(Either.scala:200)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:384)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:343)
	at dotty.tools.repl.ReplDriver.$anonfun$4(ReplDriver.scala:252)
	at dotty.tools.repl.JLineTerminal.withMonitoringCtrlC(JLineTerminal.scala:125)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:253)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:259)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:293)
	at dotty.tools.repl.ReplDriver.runBody$$anonfun$1(ReplDriver.scala:267)
	at dotty.tools.repl.ScalaClassLoader$.asContext(ScalaClassLoader.scala:32)
	at dotty.tools.repl.ReplDriver.runBody(ReplDriver.scala:267)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:259)
	at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:166)
	at dotty.tools.repl.Main$.main(Main.scala:8)
	at dotty.tools.repl.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