@@ -2428,13 +2428,22 @@ extends NamingMsg(DoubleDefinitionID):
2428
2428
def explain (using Context ) =
2429
2429
def givenAddendum =
2430
2430
def isGivenName (sym : Symbol ) = sym.name.startsWith(" given_" ) // Desugar.inventGivenName
2431
+ def print (tpe : Type ): String =
2432
+ def addParams (tpe : Type ): List [String ] = tpe match
2433
+ case tpe : MethodType =>
2434
+ val s = if tpe.isContextualMethod then i " ( ${tpe.paramInfos}%, %) => " else " "
2435
+ s :: addParams(tpe.resType)
2436
+ case tpe : PolyType =>
2437
+ i " [ ${tpe.paramNames}%, %] => " :: addParams(tpe.resType)
2438
+ case tpe =>
2439
+ i " $tpe" :: Nil
2440
+ addParams(tpe).mkString(" " )
2431
2441
if decl.is(Given ) && previousDecl.is(Given ) && isGivenName(decl) && isGivenName(previousDecl) then
2432
- i """
2433
- |3. Provide an explicit, unique name to given definitions, since the names
2434
- | assigned to anonymous givens may clash. For example:
2435
- |
2436
- | given myGiven: ${atPhase(typerPhase)(decl.info)}
2437
- | """
2442
+ i """ | Provide an explicit, unique name to given definitions,
2443
+ | since the names assigned to anonymous givens may clash. For example:
2444
+ |
2445
+ | given myGiven: ${print(atPhase(typerPhase)(decl.info))}
2446
+ | """
2438
2447
else " "
2439
2448
decl.signature.matchDegree(previousDecl.signature) match
2440
2449
case FullMatch =>
@@ -2458,15 +2467,15 @@ extends NamingMsg(DoubleDefinitionID):
2458
2467
|
2459
2468
|so the compiler cannot keep both: the generated bytecode symbols would collide.
2460
2469
|
2461
- |To fix this error, you need to disambiguate the two definitions. You can either :
2470
+ |To fix this error, you must disambiguate the two definitions by doing one of the following :
2462
2471
|
2463
- |1. Rename one of the definitions, or
2472
+ |1. Rename one of the definitions. $givenAddendum
2464
2473
|2. Keep the same names in source but give one definition a distinct
2465
2474
| bytecode-level name via `@targetName`; for example:
2466
2475
|
2467
2476
| @targetName(" ${decl.name.show}_2")
2468
2477
| ${atPhase(typerPhase)(decl.showDcl)}
2469
- | $givenAddendum
2478
+ |
2470
2479
|Choose the `@targetName` argument carefully: it is the name that will be used
2471
2480
|when calling the method externally, so it should be unique and descriptive.
2472
2481
| """
0 commit comments