@@ -2390,13 +2390,22 @@ extends NamingMsg(DoubleDefinitionID):
2390
2390
def explain (using Context ) =
2391
2391
def givenAddendum =
2392
2392
def isGivenName (sym : Symbol ) = sym.name.startsWith(" given_" ) // Desugar.inventGivenName
2393
+ def print (tpe : Type ): String =
2394
+ def addParams (tpe : Type ): List [String ] = tpe match
2395
+ case tpe : MethodType =>
2396
+ val s = if tpe.isContextualMethod then i " ( ${tpe.paramInfos}%, %) => " else " "
2397
+ s :: addParams(tpe.resType)
2398
+ case tpe : PolyType =>
2399
+ i " [ ${tpe.paramNames}%, %] => " :: addParams(tpe.resType)
2400
+ case tpe =>
2401
+ i " $tpe" :: Nil
2402
+ addParams(tpe).mkString(" " )
2393
2403
if decl.is(Given ) && previousDecl.is(Given ) && isGivenName(decl) && isGivenName(previousDecl) then
2394
- i """
2395
- |3. Provide an explicit, unique name to given definitions, since the names
2396
- | assigned to anonymous givens may clash. For example:
2397
- |
2398
- | given myGiven: ${atPhase(typerPhase)(decl.info)}
2399
- | """
2404
+ i """ | Provide an explicit, unique name to given definitions,
2405
+ | since the names assigned to anonymous givens may clash. For example:
2406
+ |
2407
+ | given myGiven: ${print(atPhase(typerPhase)(decl.info))}
2408
+ | """
2400
2409
else " "
2401
2410
decl.signature.matchDegree(previousDecl.signature) match
2402
2411
case FullMatch =>
@@ -2420,15 +2429,15 @@ extends NamingMsg(DoubleDefinitionID):
2420
2429
|
2421
2430
|so the compiler cannot keep both: the generated bytecode symbols would collide.
2422
2431
|
2423
- |To fix this error, you need to disambiguate the two definitions. You can either :
2432
+ |To fix this error, you must disambiguate the two definitions by doing one of the following :
2424
2433
|
2425
- |1. Rename one of the definitions, or
2434
+ |1. Rename one of the definitions. $givenAddendum
2426
2435
|2. Keep the same names in source but give one definition a distinct
2427
2436
| bytecode-level name via `@targetName`; for example:
2428
2437
|
2429
2438
| @targetName(" ${decl.name.show}_2")
2430
2439
| ${atPhase(typerPhase)(decl.showDcl)}
2431
- | $givenAddendum
2440
+ |
2432
2441
|Choose the `@targetName` argument carefully: it is the name that will be used
2433
2442
|when calling the method externally, so it should be unique and descriptive.
2434
2443
| """
0 commit comments