Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to disambiguate overloaded reference regression on Scala.js #13860

Closed
armanbilge opened this issue Nov 1, 2021 · 0 comments · Fixed by #13870
Closed

Failure to disambiguate overloaded reference regression on Scala.js #13860

armanbilge opened this issue Nov 1, 2021 · 0 comments · Fixed by #13870
Assignees
Labels
area:scala.js itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Milestone

Comments

@armanbilge
Copy link
Contributor

This came up when adding spire to the community build:
https://github.com/lampepfl/dotty/runs/4071449490?check_suite_focus=true#step:8:9272.

Spire (and this minimization) compiles fine under 3.1.1-RC1 and also on JVM on the nightly.

Compiler version

3.1.2-RC1-bin-20211029-ad5c714-NIGHTLY
Scala.js 1.7.1

Minimized code

package crash

class Foo

trait Companion[A]:
  def bar(x: Long = 0): A

object Foo extends Companion[Foo]:
  def bar(x: Long = 0): Foo = ???

def crash = Foo.bar()

Output (click arrow to expand)

[info] exception occurred while compiling /workspace/sandbox/src/main/scala/Cmcw5.scala, /workspace/sandbox/src/main/scala/Foo.scala
Failure to disambiguate overloaded reference with
  method bar in object Foo: (x: Long): Object  and
  method bar in object Foo: (x: Long): crash.Foo while compiling /workspace/sandbox/src/main/scala/Cmcw5.scala, /workspace/sandbox/src/main/scala/Foo.scala
[error] ## Exception when compiling 2 sources to /workspace/sandbox/target/scala-3.1.2-RC1-bin-20211029-ad5c714-NIGHTLY/classes
[error] dotty.tools.dotc.core.TypeError: Failure to disambiguate overloaded reference with
[error]   method bar in object Foo: (x: Long): Object  and
[error]   method bar in object Foo: (x: Long): crash.Foo
[error] dotty.tools.dotc.core.Denotations$MultiDenotation.suchThat(Denotations.scala:1244)
[error] dotty.tools.backend.sjs.JSCodeGen$DefaultParamInfo.attachedMethod(JSCodeGen.scala:4709)
[error] dotty.tools.backend.sjs.JSCodeGen.isDefaultParamOfJSNativeDef$1(JSCodeGen.scala:798)
[error] dotty.tools.backend.sjs.JSCodeGen.isExcluded$1(JSCodeGen.scala:806)
[error] dotty.tools.backend.sjs.JSCodeGen.$anonfun$11(JSCodeGen.scala:811)
[error] scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:472)
[error] scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:574)
[error] scala.collection.immutable.List.prependedAll(List.scala:155)
[error] scala.collection.immutable.List$.from(List.scala:684)
[error] scala.collection.immutable.List$.from(List.scala:681)
[error] scala.collection.IterableOps$WithFilter.map(Iterable.scala:884)
[error] dotty.tools.backend.sjs.JSCodeGen.genStaticForwardersFromModuleClass(JSCodeGen.scala:839)
[error] dotty.tools.backend.sjs.JSCodeGen.genStaticForwardersForClassOrInterface(JSCodeGen.scala:763)
[error] dotty.tools.backend.sjs.JSCodeGen.genScalaClass(JSCodeGen.scala:447)
[error] dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit$$anonfun$3$$anonfun$1(JSCodeGen.scala:245)
[error] dotty.tools.backend.sjs.ScopedVar$.withScopedVars(ScopedVar.scala:35)
[error] dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit$$anonfun$3(JSCodeGen.scala:249)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit(JSCodeGen.scala:251)
[error] dotty.tools.backend.sjs.JSCodeGen.run(JSCodeGen.scala:163)
[error] dotty.tools.backend.sjs.GenSJSIR.run(GenSJSIR.scala:15)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
[error] scala.collection.immutable.List.map(List.scala:250)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:261)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:272)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:280)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:289)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:222)
[error] dotty.tools.dotc.Run.compile(Run.scala:206)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:175)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:173)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:459)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:414)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:501)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:401)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:167)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2357)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2314)
[error] sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2310)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] java.base/java.lang.Thread.run(Thread.java:833)
[error]            
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) dotty.tools.dotc.core.TypeError: Failure to disambiguate overloaded reference with
[error]   method bar in object Foo: (x: Long): Object  and
[error]   method bar in object Foo: (x: Long): crash.Foo
[error] Total time: 1 s, completed Nov 1, 2021, 8:54:13 PM
sjrd added a commit to dotty-staging/dotty that referenced this issue Nov 3, 2021
@sjrd sjrd added this to the 3.1.1 milestone Nov 3, 2021
@sjrd sjrd added the regression This worked in a previous version but doesn't anymore label Nov 3, 2021
nicolasstucki added a commit that referenced this issue Nov 17, 2021
…arams-with-bridge

Fix #13860: Ignore bridges when looking for a default getter's attached method.
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
@Kordyjan Kordyjan modified the milestones: 3.1.1, 3.1.2 Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:scala.js itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants