Skip to content

Crashes when calling trait constructor from secondary constructor #8186

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

Closed
SrTobi opened this issue Feb 4, 2020 · 4 comments
Closed

Crashes when calling trait constructor from secondary constructor #8186

SrTobi opened this issue Feb 4, 2020 · 4 comments

Comments

@SrTobi
Copy link
Contributor

SrTobi commented Feb 4, 2020

minimized code

object Main {
  trait Test() {
    def this(x: Int) = this()
  }
}
scalaVersion := "0.22.0-bin-20200202-c2478a3-NIGHTLY"

Crash output (click arrow to expand)

sbt:dotty-example-project> compile
[info] Compiling 1 Scala source to /home/tobi/workspace/playground/dotty-test/target/scala-0.22/classes ...
Error while emitting Main.scala
[info] exception occurred while compiling /home/tobi/workspace/playground/dotty-test/src/main/scala/Main.scala
[error] ## Exception when compiling 1 sources to /home/tobi/workspace/playground/dotty-test/target/scala-0.22/classes
[error] java.lang.AssertionError: assertion failed: denotation module class <empty> invalid in run 1. ValidFor: Period(1..75, run = 2)
[error] dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.updateValidity(Denotations.scala:834)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:863)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:918)
[error] dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:494)
[error] dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:489)
[error] dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:483)
[error] dotty.tools.dotc.core.SymDenotations.stillValidInOwner(SymDenotations.scala:64)
[error] dotty.tools.dotc.core.Contexts$Context.stillValidInOwner(Contexts.scala:75)
[error] dotty.tools.dotc.core.SymDenotations.stillValid(SymDenotations.scala:60)
[error] dotty.tools.dotc.core.Contexts$Context.stillValid(Contexts.scala:75)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:863)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:918)
[error] dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:494)
[error] dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:489)
[error] dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:483)
[error] dotty.tools.dotc.core.SymDenotations.stillValidInOwner(SymDenotations.scala:64)
[error] dotty.tools.dotc.core.Contexts$Context.stillValidInOwner(Contexts.scala:75)
[error] dotty.tools.dotc.core.SymDenotations.stillValid(SymDenotations.scala:60)
[error] dotty.tools.dotc.core.Contexts$Context.stillValid(Contexts.scala:75)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:863)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:918)
[error] dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:494)
[error] dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:489)
[error] dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:483)
[error] dotty.tools.dotc.core.SymDenotations.stillValidInOwner(SymDenotations.scala:64)
[error] dotty.tools.dotc.core.Contexts$Context.stillValidInOwner(Contexts.scala:75)
[error] dotty.tools.dotc.core.SymDenotations.stillValid(SymDenotations.scala:60)
[error] dotty.tools.dotc.core.Contexts$Context.stillValid(Contexts.scala:75)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:863)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:918)
[error] dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:494)
[error] dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:489)
[error] dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:483)
[error] dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:855)
[error] dotty.tools.dotc.core.MergeError.showSymbol(TypeErrors.scala:167)
[error] dotty.tools.dotc.core.MergeError.toMessage(TypeErrors.scala:188)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:54)
[error] dotty.tools.dotc.Driver.process(Driver.scala:189)
[error] dotty.tools.dotc.Main.process(Main.scala)
[error] xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
[error] xsbt.CompilerInterface.run(CompilerInterface.java:41)
[error] jdk.internal.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
[error] java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
[error] sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
[error] sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
[error] sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
[error] sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
[error] sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
[error] sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
[error] sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:1762)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:1735)
[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:67)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] sbt.Execute.work(Execute.scala:290)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] java.base/java.lang.Thread.run(Thread.java:834)
[error]            
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) java.lang.AssertionError: assertion failed: denotation module class <empty> invalid in run 1. ValidFor: Period(1..75, run = 2)
@nicolasstucki
Copy link
Contributor

Same happens with

trait Test(x: Int) {
  def this() = this(3)
}

@nicolasstucki nicolasstucki changed the title Crashes when calling empty trait constructor from secondary constructor Crashes when calling trait constructor from secondary constructor Feb 4, 2020
@nicolasstucki
Copy link
Contributor

https://docs.scala-lang.org/sips/trait-parameters.html mentions that secondary constructors are not allowed

@nicolasstucki nicolasstucki self-assigned this Feb 4, 2020
@SrTobi
Copy link
Contributor Author

SrTobi commented Feb 4, 2020

Yes. I found that out afterwards. Why is this forbidden btw? Is there a technical problem?

@nicolasstucki
Copy link
Contributor

The wording in the SIP seems to indicate that this could be a potential extension.

nicolasstucki added a commit that referenced this issue Feb 4, 2020
Fix #8186: Check trait secondary constructors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants