From 26905de637c81230379c3a3d1b31044f297a24c4 Mon Sep 17 00:00:00 2001 From: tarao Date: Mon, 25 Dec 2023 14:01:53 +0900 Subject: [PATCH] Try to fix the error message. --- docs/advanced/generic.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/advanced/generic.md b/docs/advanced/generic.md index 744fd33..a206213 100644 --- a/docs/advanced/generic.md +++ b/docs/advanced/generic.md @@ -108,18 +108,16 @@ You may think that you can define a method to concatenate two generic records by `Concat` but it doesn't work in a simple way. ```scala mdoc:fail -def concat[R1 <: %, R2 <: %, RR <: %](r1: R1, r2: R2)(using - Concat.Aux[R1, R2, RR], -): RR = r1 ++ r2 +def concat[R1 <: %, R2 <: %, RR <: %](r1: R1, r2: R2)(using Concat.Aux[R1, R2, RR]): RR = + r1 ++ r2 ``` The problem is that the right-hand-side argument type of `++` is restricted to be a concrete type for type safety. In this case, defining an inline method makes it work. ```scala mdoc:mline -inline def concat[R1 <: %, R2 <: %, RR <: %](r1: R1, r2: R2)(using - Concat.Aux[R1, R2, RR], -): RR = r1 ++ r2 +inline def concat[R1 <: %, R2 <: %, RR <: %](r1: R1, r2: R2)(using Concat.Aux[R1, R2, RR]): RR = + r1 ++ r2 concat(%(name = "tarao"), %(age = 3)) ```