Skip to content

Crash when compiling ekrich/sconfig #7175

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
ekrich opened this issue Sep 6, 2019 · 8 comments
Closed

Crash when compiling ekrich/sconfig #7175

ekrich opened this issue Sep 6, 2019 · 8 comments

Comments

@ekrich
Copy link
Contributor

ekrich commented Sep 6, 2019

minimized code

When preparing sconfig to compile with Dotty. There is currently another issue as well: #7174

https://github.com/ekrich/sconfig/tree/topic/dotty

Using the branch above:

$ sbt
sbt:sconfig-root> ++0.18.1-RC1
sbt:sconfig-root> compile

Notes from Gitter - September 5, 2019 5:47 PM

Portions removed.

Stack trace
[info] Compiling 101 Scala sources and 1 Java source to /Users/eric/workspace/sconfig/sconfig/jvm/target/scala-0.18/classes ...
[error] -- Error: /Users/eric/workspace/sconfig/sconfig/shared/src/main/scala/org/ekrich/config/ConfigSyntax.scala:17:34 
[error] 17 |    extends jl.Enum[ConfigSyntax](name, ordinal)
[error]    |                                  ^^^^
[error]    |too many arguments for constructor Enum: (): Enum[org.ekrich.config.ConfigSyntax]
[error] -- Error: /Users/eric/workspace/sconfig/sconfig/shared/src/main/scala/org/ekrich/config/ConfigValueType.scala:13:37 
[error] 13 |    extends jl.Enum[ConfigValueType](name, ordinal)
[error]    |                                     ^^^^
[error]    |too many arguments for constructor Enum: (): Enum[org.ekrich.config.ConfigValueType]
assertion failure for org.ekrich.config.impl.SimpleConfigList <:< ?{ concatenate: ? }, frozen = false
[info] exception occurred while typechecking /Users/eric/workspace/sconfig/sconfig/shared/src/main/scala/org/ekrich/config/impl/ConfigConcatenation.scala
[info] exception occurred while compiling /Users/eric/workspace/sconfig/sconfig/jvm/src/main/java/org/ekrich/config/Optional.java,
...
[error] ## Exception when compiling 102 sources to /Users/eric/workspace/sconfig/sconfig/jvm/target/scala-0.18/classes
[error] assertion failed: org.ekrich.config.ConfigOrigin & (): org.ekrich.config.impl.SimpleConfigOrigin / TypeRef(ThisType(TypeRef(NoPrefix,module class config)),class ConfigOrigin) & MethodType(List(), List(), TypeRef(ThisType(TypeRef(NoPrefix,module class impl)),class SimpleConfigOrigin))
[error] dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
[error] dotty.tools.dotc.core.Types$AndType$.apply(Types.scala:2778)
[error] dotty.tools.dotc.core.TypeComparer.andType$$anonfun$1(TypeComparer.scala:1923)
[error] dotty.tools.dotc.core.TypeComparer.liftIfHK(TypeComparer.scala:1962)
[error] dotty.tools.dotc.core.TypeComparer.andTypeGen(TypeComparer.scala:1900)
[error] dotty.tools.dotc.core.TypeComparer.andType(TypeComparer.scala:1923)
[error] dotty.tools.dotc.core.TypeComparer.glb(TypeComparer.scala:1722)
[error] dotty.tools.dotc.core.Types$Type.$amp(Types.scala:951)
[error] dotty.tools.dotc.core.Denotations$.infoMeet(Denotations.scala:655)
[error] dotty.tools.dotc.core.Denotations$Denotation.mergeSingleDenot$1(Denotations.scala:480)
[error] dotty.tools.dotc.core.Denotations$Denotation.mergeDenot$1(Denotations.scala:400)
[error] dotty.tools.dotc.core.Denotations$Denotation.$amp(Denotations.scala:503)
[error] dotty.tools.dotc.core.Denotations$DenotUnion.toDenot(Denotations.scala:1258)
[error] dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1816)
[error] dotty.tools.dotc.core.Types$Type.go$1(Types.scala:565)
[error] dotty.tools.dotc.core.Types$Type.findMember(Types.scala:715)
...
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error] java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error] java.lang.Thread.run(Thread.java:748)
[error]            
[error] java.lang.AssertionError: assertion failed: org.ekrich.config.ConfigOrigin & (): org.ekrich.config.impl.SimpleConfigOrigin / TypeRef(ThisType(TypeRef(NoPrefix,module class config)),class ConfigOrigin) & MethodType(List(), List(), TypeRef(ThisType(TypeRef(NoPrefix,module class impl)),class SimpleConfigOrigin))
[error] 	at dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
[error] 	at dotty.tools.dotc.core.Types$AndType$.apply(Types.scala:2778)
[error] 	at dotty.tools.dotc.core.TypeComparer.andType$$anonfun$1(TypeComparer.scala:1923)
[error] 	at dotty.tools.dotc.core.TypeComparer.liftIfHK(TypeComparer.scala:1962)
[error] 	at dotty.tools.dotc.core.TypeComparer.andTypeGen(TypeComparer.scala:1900)
[error] 	at dotty.tools.dotc.core.TypeComparer.andType(TypeComparer.scala:1923)
[error] 	at dotty.tools.dotc.core.TypeComparer.glb(TypeComparer.scala:1722)
[error] 	at dotty.tools.dotc.core.Types$Type.$amp(Types.scala:951)
[error] 	at dotty.tools.dotc.core.Denotations$.infoMeet(Denotations.scala:655)
[error] 	at dotty.tools.dotc.core.Denotations$Denotation.mergeSingleDenot$1(Denotations.scala:480)
[error] 	at dotty.tools.dotc.core.Denotations$Denotation.mergeDenot$1(Denotations.scala:400)
[error] 	at dotty.tools.dotc.core.Denotations$Denotation.$amp(Denotations.scala:503)
[error] 	at dotty.tools.dotc.core.Denotations$DenotUnion.toDenot(Denotations.scala:1258)
[error] 	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1816)
[error] 	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:565)
[error] 	at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:715)
[error] 	at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:548)
[error] 	at dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:538)
[error] 	at dotty.tools.dotc.typer.TypeAssigner.test$1(TypeAssigner.scala:202)
[error] 	at dotty.tools.dotc.typer.TypeAssigner.ensureAccessible(TypeAssigner.scala:229)
...
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] 	at sbt.Execute.work(Execute.scala:278)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] (sconfigJVM / Compile / compileIncremental) java.lang.AssertionError: assertion failed: org.ekrich.config.ConfigOrigin & (): org.ekrich.config.impl.SimpleConfigOrigin / TypeRef(ThisType(TypeRef(NoPrefix,module class config)),class ConfigOrigin) & MethodType(List(), List(), TypeRef(ThisType(TypeRef(NoPrefix,module class impl)),class SimpleConfigOrigin))
@OlivierBlanvillain
Copy link
Contributor

Thanks for the bug report, I think there is a higher chance of having someone looking into it if it can be minimized into a self contained example.

@ekrich
Copy link
Contributor Author

ekrich commented Sep 6, 2019

I will try and produce a minimization.

@ekrich
Copy link
Contributor Author

ekrich commented Sep 6, 2019

Here is reproducer that produces an error which may be the underlying cause of the crash. This obviously compiles in scalac and is certainly not pretty but works. It is hard to know exactly the cause but these are some of the core types in the system. Adding parens to ConfigValue origin or removing it from the override in AbstractConfigValue clears the error. I will do some more investigation with the actual project.

object foo {
  def main(args: Array[String]): Unit = println("Dotty")
  
  import java.net.URL
  import java.util.List
  
  trait ConfigOrigin {
    def description: String
    def filename: String
    def url: URL
    def resource: String
    def lineNumber: Int
    def comments: List[String]
    def withComments(comments: List[String]): ConfigOrigin
    def withLineNumber(lineNumber: Int): ConfigOrigin
  }

  
  trait ConfigValue extends ConfigMergeable {
    def origin: ConfigOrigin
    //def valueType: ConfigValueType
    def unwrapped: AnyRef
    def render: String
    //def render(options: ConfigRenderOptions): String
    override def withFallback(other: ConfigMergeable): ConfigValue
    //def atPath(path: String): Config
    //def atKey(key: String): Config
    def withOrigin(origin: ConfigOrigin): ConfigValue
  }

  
  trait ConfigMergeable {
    def withFallback(other: ConfigMergeable): ConfigMergeable
  }
  
  trait MergeableValue extends ConfigMergeable {
    def toFallbackValue(): ConfigValue
  }
  
  // no impl
  final class SimpleConfigOrigin extends ConfigOrigin {
    def comments: java.util.List[String] = ???
    def description: String = ???
    def filename: String = ???
    def lineNumber: Int = ???
    def resource: String = ???
    def url: java.net.URL = ???
    def withComments(comments: java.util.List[String]): foo.ConfigOrigin = ???
    def withLineNumber(lineNumber: Int): foo.ConfigOrigin = ???
  }
  
  abstract class AbstractConfigValue (val _origin: ConfigOrigin)
    extends ConfigValue
    with MergeableValue {

  override def origin(): SimpleConfigOrigin =
    this._origin.asInstanceOf[SimpleConfigOrigin]
  }
}

@ekrich
Copy link
Contributor Author

ekrich commented Sep 6, 2019

I removed the parens on AbstractConfigValue.origin and that indeed that removes the crash when compiling the actual project. I can also do the opposite and add them on the trait ConfigValue with the same effect.

@ekrich
Copy link
Contributor Author

ekrich commented Sep 6, 2019

One other point. Adding -language:Scala2 made no difference.

@ekrich
Copy link
Contributor Author

ekrich commented Sep 10, 2019

This is the commit that errors since I have moved past that commit.
ekrich/sconfig@db75a72

odersky added a commit to dotty-staging/dotty that referenced this issue Oct 15, 2019
@odersky
Copy link
Contributor

odersky commented Oct 15, 2019

After #7430, I get

-- Error: i7175.scala:56:15 ----------------------------------------------------
56 |  override def origin(): SimpleConfigOrigin =
   |               ^
   |error overriding method origin in trait ConfigValue of type => foo.ConfigOrigin;
   |  method origin of type (): foo.SimpleConfigOrigin has incompatible type
one error found

Once I change origin to be parameterless, it compiles.

@odersky odersky closed this as completed Oct 15, 2019
@ekrich
Copy link
Contributor Author

ekrich commented Oct 15, 2019

Thank-you!

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

3 participants