You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.StackOverflowError
at scala.tools.nsc.symtab.Symbols$ClassSymbol.typeOfThis(Symbols.scala:2074)
at scala.tools.nsc.symtab.Types$ThisType.underlying(Types.scala:1122)
at scala.tools.nsc.symtab.Types$SimpleTypeProxy$class.boundSyms(Types.scala:189)
at scala.tools.nsc.symtab.Types$SingletonType.boundSyms(Types.scala:1040)
at scala.tools.nsc.symtab.Types$SubstMap.apply(Types.scala:3557)
at scala.tools.nsc.symtab.Types$SubstSymMap.apply(Types.scala:3603)
at scala.tools.nsc.symtab.Types$SubstSymMap.apply(Types.scala:3584)
...
The crash goes away, and the the program compiles, when the contravariance is removed from the R type parameter in trait MatrixAdder.
If the type parameter S is removed throughout, the crash goes away, but the program fails to compile due to adderImplicit not being found. Is this correct behavior?
Thanks.
The text was updated successfully, but these errors were encountered:
@paulp said:
I think it should be incorrect by definition, that the following code fails to compile with the contravariant R, but succeeds with an invariant R.
There are a ton of open and closed tickets on contravariance and implicits. Suffice to say that there are problems, and there is not yet universal agreement on how to fix them or who might do the fixing.
This still crashes the compiler with Scala 2.12.7, but it has been fixed in the current branch 2.13.x. Which is to say, that compiling the program in the bug description no longer crashes the compiler. However, the compiler rejects the program, because it can not resolve the implicit in the call to .foo.
I am not sure if I, per Paul Philipps comment, the compiler should accept and compile the program or not.
The following will crash the compiler with a stack overflow,
The top of the stack trace is,
The crash goes away, and the the program compiles, when the contravariance is removed from the R type parameter in trait MatrixAdder.
If the type parameter S is removed throughout, the crash goes away, but the program fails to compile due to
adderImplicit
not being found. Is this correct behavior?Thanks.
The text was updated successfully, but these errors were encountered: