Skip to content

Match-error in JVM backend when emitting HK-type with type lambda contianing primtive #26786

Description

@WojciechMazur

Based on the OpenCB failure in dfianthdl/dfhdl

Most likely caused inside referenceTypeSignature() in the JVM backend while handling Ljava/lang/Object;LCheck<Z>; signature (the <Z> part might be invalid here, we probably should not have a priimitive type in generic

@tailrec private def referenceTypeSignature(): Unit = getCurrentAndSkip() match {
case 'L' =>
val start = index
var seenDollar = false
while (!isClassNameEnd(current)) {
seenDollar ||= current == '$'
index += 1
}
// OPT: avoid allocations when collecting only nested classes and only a top-level class is encountered
val topLevelIndex = index
lazy val names = {
val n = new java.lang.StringBuilder(32)
n.append(sig, start, topLevelIndex)
n
}
if ((current == '.' || seenDollar) || !nestedOnly) {
visitInternalName(names.toString)
}
typeArguments()
while (current == '.') {
skip()
names.append('$')
appendUntil(names, isClassNameEnd)
visitInternalName(names.toString)
typeArguments()
}
accept(';')
case 'T' =>
skipUntilDelimiter(';')
skip()
case '[' =>
if (isBaseType(current)) skip()
else referenceTypeSignature()
}

Compiler version

3.9.0-RC5 (backported)

Last good release: 3.10.0-RC1-bin-20260803-11ca8f7-NIGHTLY
First bad release: 3.10.0-RC1-bin-20260804-9db016f-NIGHTLY

Biect points to #26632 - it's a root cause, the underlying issue was already there but hidden

Minimized code

import compiletime.ops.int.>

trait Check[Cond[T <: Int] <: Boolean]:
  def apply(arg: Int): Unit

type CondT = [t <: Int] =>> t > 0

val c: Check[CondT] = new Check[CondT]:
  def apply(arg: Int): Unit = ()

Output

Error while emitting test$package$
Z (of class java.lang.Character)
Error while emitting test$package
Z (of class java.lang.Character)
Error while emitting test$package$$anon$1
Z (of class java.lang.Character)
3 errors found
Compilation failed

Expectation

Should compile

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions