Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeriveSchema macro - NoSuchElementException for Enums which extend a trait #748

Open
xsistens opened this issue Oct 4, 2024 · 0 comments

Comments

@xsistens
Copy link

xsistens commented Oct 4, 2024

Currently when trying to derive an Enum in scala3 where a case is extending a trait it will throw a NoSuchElementException because there is no classSymbol available.

trait A

enum B(val name: String) derives Schema:
  case C            extends B("Name") with A

The stacktrace of the result error looks like this:

|enum B(val name: String) derives Schema:                                                                                                                                                                                                                                                             
[error]    |                                   ^                                                                                                                                                                                                                                                                   
[error]    |value derived is not a member of object zio.schema.Schema.                                                                                                                                                                                                                                             
[error]    |An extension method was tried, but could not be fully constructed:                                                                                                                                                                                                                                     
[error]    |                                                                                                                                                                                                                                                                                                       
[error]    |    ???                                                                                                                                                                                                                                                                                                
[error]    |                                                                                                                                                                                                                                                                                                       
[error]    |    failed with:
[error]    |                                                                                                                                                                                                                                                                                                       
[error]    |        Exception occurred while executing macro expansion.                                                                                                                                                                                                                                            
[error]    |        java.util.NoSuchElementException: None.get                                                                                                                                                                                                                                                     
[error]    |            at scala.None$.get(Option.scala:627)                                                                                                                                                                                                                                                       
[error]    |            at scala.None$.get(Option.scala:626)                                                                                                                                                                                                                                                       
[error]    |            at zio.schema.DeriveSchema.$anonfun$35(DeriveSchema.scala:204)                                                                                                                                                                                                                             
[error]    |            at zio.schema.DeriveSchema.$anonfun$adapted$15(DeriveSchema.scala:204)                                                                                                                                                                                                                     
[error]    |            at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:111)                                                                                                                                                                                                        
[error]    |            at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1568)                                                                                                                                                                                                                 
[error]    |            at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:136)
[error]    |            at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1640)                                                                                                                                                                                                      
[error]    |            at scala.collection.immutable.List.mapConserve(List.scala:473)                                                                                                                                                                                                                             
[error]    |            at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1640)                                                                                                                                                                                                                 
[error]    |            at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1534)                                                                                                                                                                                                                 
[error]    |            at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:136)                                                                                                                                                                                                        
[error]    |            at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:153)                                                                                                                                                                                                             
[error]    |            at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:89)                                                                                                                                                                                                             
[error]    |            at scala.quoted.runtime.impl.QuotesImpl.unpickleExprV2(QuotesImpl.scala:3262)                                                                                                                                                                                                              
[error]    |            at zio.schema.DeriveSchema.deriveCaseClass(DeriveSchema.scala:204)                                                                                                                                                                                                                         
[error]    |            at zio.schema.DeriveSchema.deriveSchema(DeriveSchema.scala:96)                                                                                                                                                                                                                             
[error]    |            at zio.schema.DeriveSchema.deriveCase(DeriveSchema.scala:558)                                                                                                                                                                                                                              
[error]    |            at zio.schema.DeriveSchema.$anonfun$59(DeriveSchema.scala:381)                                                                                                                                                                                                                             
[error]    |            at scala.collection.immutable.List.map(List.scala:251)                                                                                                                                                                                                                                     
[error]    |            at zio.schema.DeriveSchema.deriveEnum(DeriveSchema.scala:381)                                                                                                                                                                                                                              
[error]    |            at zio.schema.DeriveSchema.deriveSchema(DeriveSchema.scala:94)                                                                                                                                                                                                                             
[error]    |            at zio.schema.DeriveSchema$.deriveSchema(DeriveSchema.scala:18)                                                                                                                                                                                                                            
[error]    |            at zio.schema.DeriveSchema$.inline$deriveSchema(DeriveSchema.scala:17)

Before the merge of commit 5c8e7eb it was working fine without any problems. Sadly I'm not experienced enough with Macros to figure out whats the actual problem or fix it :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant