@@ -350,14 +350,8 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
350350 val (getter, setters) = alts.partition(_.info.paramInfoss.head.isEmpty)
351351
352352 // 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)
361355
362356 val getterBody = getter.headOption.map { getterSym =>
363357 genApplyForSingleExported(new FormalArgsRegistry (0 , false ), new ExportedSymbol (getterSym, static), static)
@@ -535,7 +529,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
535529 // 2. The optional argument count restriction has triggered
536530 // 3. We only have (more than once) repeated parameters left
537531 // Therefore, we should fail
538- reportCannotDisambiguateError(jsName, alts)
532+ reportCannotDisambiguateError(jsName, alts.map(_.sym) )
539533 js.Undefined ()
540534 } else {
541535 val altsByTypeTest = groupByWithoutHashCode(alts) { exported =>
@@ -597,7 +591,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
597591 }
598592 }
599593
600- private def reportCannotDisambiguateError (jsName : JSName , alts : List [Exported ]): Unit = {
594+ private def reportCannotDisambiguateError (jsName : JSName , alts : List [Symbol ]): Unit = {
601595 val currentClass = currentClassSym.get
602596
603597 /* Find a position that is in the current class for decent error reporting.
@@ -606,21 +600,26 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
606600 * same error in all compilers.
607601 */
608602 val validPositions = alts.collect {
609- case alt if alt.sym. owner == currentClass => alt.pos
603+ case alt if alt.owner == currentClass => alt.sourcePos
610604 }
611605 val pos : SourcePosition =
612606 if (validPositions.isEmpty) currentClass.sourcePos
613607 else validPositions.maxBy(_.point)
614608
615609 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
618617
619618 val displayName = jsName.displayName
620- val altsTypesInfo = alts.map(_.typeInfo) .mkString(" \n " )
619+ val altsTypesInfo = alts.map(_.info.show).sorted .mkString(" \n " )
621620
622621 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" ,
624623 pos)
625624 }
626625
0 commit comments