@@ -350,14 +350,8 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
350
350
val (getter, setters) = alts.partition(_.info.paramInfoss.head.isEmpty)
351
351
352
352
// We can have at most one getter
353
- if (getter.sizeIs > 1 ) {
354
- /* Member export of properties should be caught earlier, so if we get
355
- * here with a non-static export, something went horribly wrong.
356
- */
357
- assert(static, s " Found more than one instance getter to export for name $jsName. " )
358
- for (duplicate <- getter.tail)
359
- report.error(s " Duplicate static getter export with name ' ${jsName.displayName}' " , duplicate)
360
- }
353
+ if (getter.sizeIs > 1 )
354
+ reportCannotDisambiguateError(jsName, alts)
361
355
362
356
val getterBody = getter.headOption.map { getterSym =>
363
357
genApplyForSingleExported(new FormalArgsRegistry (0 , false ), new ExportedSymbol (getterSym, static), static)
@@ -535,7 +529,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
535
529
// 2. The optional argument count restriction has triggered
536
530
// 3. We only have (more than once) repeated parameters left
537
531
// Therefore, we should fail
538
- reportCannotDisambiguateError(jsName, alts)
532
+ reportCannotDisambiguateError(jsName, alts.map(_.sym) )
539
533
js.Undefined ()
540
534
} else {
541
535
val altsByTypeTest = groupByWithoutHashCode(alts) { exported =>
@@ -597,7 +591,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
597
591
}
598
592
}
599
593
600
- private def reportCannotDisambiguateError (jsName : JSName , alts : List [Exported ]): Unit = {
594
+ private def reportCannotDisambiguateError (jsName : JSName , alts : List [Symbol ]): Unit = {
601
595
val currentClass = currentClassSym.get
602
596
603
597
/* Find a position that is in the current class for decent error reporting.
@@ -606,21 +600,26 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
606
600
* same error in all compilers.
607
601
*/
608
602
val validPositions = alts.collect {
609
- case alt if alt.sym. owner == currentClass => alt.pos
603
+ case alt if alt.owner == currentClass => alt.sourcePos
610
604
}
611
605
val pos : SourcePosition =
612
606
if (validPositions.isEmpty) currentClass.sourcePos
613
607
else validPositions.maxBy(_.point)
614
608
615
609
val kind =
616
- if (currentClass.isJSType) " method"
617
- else " exported method"
610
+ if (alts.head.isJSGetter) " getter"
611
+ else if (alts.head.isJSSetter) " setter"
612
+ else " method"
613
+
614
+ val fullKind =
615
+ if (currentClass.isJSType) kind
616
+ else " exported " + kind
618
617
619
618
val displayName = jsName.displayName
620
- val altsTypesInfo = alts.map(_.typeInfo) .mkString(" \n " )
619
+ val altsTypesInfo = alts.map(_.info.show).sorted .mkString(" \n " )
621
620
622
621
report.error(
623
- s " Cannot disambiguate overloads for $kind $displayName with types \n $altsTypesInfo" ,
622
+ s " Cannot disambiguate overloads for $fullKind $displayName with types \n $altsTypesInfo" ,
624
623
pos)
625
624
}
626
625
0 commit comments