bug icon indicating copy to clipboard operation
bug copied to clipboard

Infinite recursion between bridge methods for `@specialized` and manually specialized declarations of a method.

Open noresttherein opened this issue 1 year ago • 0 comments

Reproduction steps

Scala version: 2.13.12 infinite recursion in @specialized methods is nothing new, but, everything I saw so far involved multiple definitions of a method, and a call to super. This one is on new level for me.

trait I[@specialized(Int) T] {
	def hehe :T
}
trait IInt extends I[Int] {
	def hehe :Int
	def hihi = hehe
}
class Spec[@specialized(Int) T] extends I[T] {
	override def hehe :T = ???
}
class IntSpec extends Spec[Int] with IInt

(new IntSpec).hehe

Problem

Exception in thread "main" java.lang.StackOverflowError
	at IInt.hehe$mcI$sp(Playground.scala:23)
	at IInt.hehe$mcI$sp$(Playground.scala:23)
	at IntSpec.hehe$mcI$sp(Playground.scala:29)
	at Spec$mcI$sp.hehe(Playground.scala:27)
	at IInt.hehe$mcI$sp(Playground.scala:23)
	at IInt.hehe$mcI$sp$(Playground.scala:23)
	at IntSpec.hehe$mcI$sp(Playground.scala:29)
	at Spec$mcI$sp.hehe(Playground.scala:27)
	at IInt.hehe$mcI$sp(Playground.scala:23)
	at IInt.hehe$mcI$sp$(Playground.scala:23)
	at IntSpec.hehe$mcI$sp(Playground.scala:29)

Thankfully, the error goes away with removing the declaration in IInt, which doesn't really help, when I.hehe is already specialized.

Is it fixable?

noresttherein avatar Feb 11 '24 21:02 noresttherein