wvlet / airframe

Essential Building Blocks for Scala
https://wvlet.org/airframe
Apache License 2.0
631 stars 65 forks source link

airspec: Bind test cases to lazy val to avoid too large method error in <init> #3170

Open xerial opened 1 year ago

xerial commented 1 year ago

If the byte code of all test cases exceeds the 64k method-size limit of JVM, 'Method too large' compilation error can happen, especially in Scala 3.

To avoid this, each test case should use a different method body:

// test code
test { .... } 

// current macro code expanded inside <init> < 64k JVM limit
addF0( ..test body) 

// better: Define each test case using a separate method < 64k JVM Limit
lazy val __t000: AirSpecTestDef = testDefF0(... test body) 
addF0(__t000)
xerial commented 8 months ago

I need to create a reproduction spec first. I've forgotten how I encountered this issue 😅