Skip to content

Regression in arainko/ducktape under -Xcheck-macros when comparing field types #18754

Closed
@WojciechMazur

Description

@WojciechMazur

Open CB failure found in @arainko /ducktape under -Xcheck-macros. Builds logs

The issue is only present when checking types of nested members (contact.phoneNo)

Compiler version

3.4.0-RC1-bin-20231023-44a537b-NIGHTLY
Works in 3.3.1

Minimized code

No minimization yet, reproducer:

//> using option -Xcheck-macros
//> using dep "io.github.arainko::ducktape:0.1.11"
import io.github.arainko.ducktape.*

final case class Primitive(contact: PrimitiveContactInfo)
final case class PrimitiveContactInfo(phoneNo: String)

final case class Complex(contact: ComplexContactInfo)
final case class ComplexContactInfo(phoneNo: PhoneNumber)
final case class PhoneNumber(value: String) extends AnyVal

def Test() = {
  given Transformer[String, PhoneNumber] = str => PhoneNumber(str + "-LOCAL")
  
  val primitive: Primitive = ???
  val _ = primitive.into[Complex].transform()
}

Output

-- Error: /Users/wmazur/projects/sandbox/main.scala:16:43 ----------------------
16 |  val _ = primitive.into[Complex].transform()
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |Malformed tree was found while expanding macro with -Xcheck-macros.
   |               |The tree does not conform to the compiler's tree invariants.
   |               |
   |               |Macro was:
   |               |scala.quoted.runtime.Expr.splice[Complex](((evidence$7: scala.quoted.Quotes) ?=> io.github.arainko.ducktape.internal.macros.Transformations.inline$transformConfiguredMacro[Primitive, Complex](scala.quoted.runtime.Expr.quote[Primitive](source$proxy1).apply(using evidence$7), scala.quoted.runtime.Expr.quote[scala.collection.immutable.Seq[io.github.arainko.ducktape.BuilderConfig$package.BuilderConfig[Primitive, Complex]]](: _*).apply(using evidence$7))(scala.quoted.Type.of[Primitive](evidence$7), scala.quoted.Type.of[Complex](evidence$7), evidence$7)))
   |               |
   |               |The macro returned:
   |               |new Complex(contact = {
   |  val LowPriorityTransformerInstances_this: io.github.arainko.ducktape.Transformer.type = io.github.arainko.ducktape.Transformer
   |  new ComplexContactInfo(phoneNo = given_Transformer_String_PhoneNumber.transform(source$proxy1.contact.phoneNo))
   |})
   |               |
   |               |Error:
   |               |assertion failed: Types differ
   |Original type : (source.phoneNo : String)
   |After checking: (source$proxy1.contact.phoneNo : String)
   |Original tree : source$proxy1.contact.phoneNo
   |After checking: source$proxy1.contact.phoneNo
   |Why different :
   |             Subtype trace:
   |  ==> (source$proxy1.contact.phoneNo : String)  <:  (source.phoneNo : String)
   |    ==> (source$proxy1.contact : PrimitiveContactInfo)  <:  (source : PrimitiveContactInfo)
   |      ==> PrimitiveContactInfo  <:  (source : PrimitiveContactInfo) (left is approximated)
   |      <== PrimitiveContactInfo  <:  (source : PrimitiveContactInfo) (left is approximated) = false
   |    <== (source$proxy1.contact : PrimitiveContactInfo)  <:  (source : PrimitiveContactInfo) = false
   |    ==> String  <:  (source.phoneNo : String) (left is approximated)
   |      ==> String  <:  (source.phoneNo : String) (left is approximated)
   |      <== String  <:  (source.phoneNo : String) (left is approximated) = false
   |    <== String  <:  (source.phoneNo : String) (left is approximated) = false
   |  <== (source$proxy1.contact.phoneNo : String)  <:  (source.phoneNo : String) = false
   |               |
   |stacktrace available when compiling with `-Ydebug`
   |               |
   |----------------------------------------------------------------------------
   |Inline stack trace
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   |This location contains code that was inlined from Transformations.scala:69
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   |This location contains code that was inlined from Transformations.scala:69
    ----------------------------------------------------------------------------
1 error found

Expectation

Should not raise an error

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions