Open noresttherein opened 3 years ago
TIL -XX:MaxJavaStackTraceDepth=1073741823
to show higher up the stack.
at scala.reflect.internal.Types$AliasTypeRef.dealias$(Types.scala:2243)
at scala.reflect.internal.Types$AliasNoArgsTypeRef.dealias(Types.scala:2742)
at scala.reflect.internal.Types$TypeRef.customToString(Types.scala:2711)
at scala.reflect.internal.Types$TypeRef.safeToString(Types.scala:2716)
at scala.reflect.internal.tpe.TypeToStrings.typeToString(TypeToStrings.scala:55)
at scala.reflect.internal.tpe.TypeToStrings.typeToString$(TypeToStrings.scala:34)
at scala.reflect.internal.SymbolTable.typeToString(SymbolTable.scala:28)
at scala.reflect.internal.Types$Type.toString(Types.scala:950)
at java.base/java.lang.String.valueOf(String.java:4215)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:169)
at scala.collection.IterableOnceOps.addString(IterableOnce.scala:1187)
at scala.collection.IterableOnceOps.addString$(IterableOnce.scala:1179)
at scala.collection.AbstractIterable.addString(Iterable.scala:919)
at scala.collection.IterableOnceOps.mkString(IterableOnce.scala:1129)
at scala.collection.IterableOnceOps.mkString$(IterableOnce.scala:1127)
at scala.tools.nsc.typechecker.ContextErrors$InferencerContextErrors$InferErrorGen$.NotWithinBoundsErrorMessage(ContextErrors.scala:1233) at scala.tools.nsc.typechecker.ContextErrors$InferencerContextErrors$InferErrorGen$.NotWithinBounds(ContextErrors.scala:1241)
at scala.tools.nsc.typechecker.Infer$Inferencer.issueBoundsError$1(Infer.scala:981)
at scala.tools.nsc.typechecker.Infer$Inferencer.check$1(Infer.scala:987)
at scala.tools.nsc.typechecker.Infer$Inferencer.checkBounds(Infer.scala:991)
at scala.tools.nsc.typechecker.Infer$Inferencer.inferMethodInstance(Infer.scala:1089)
at scala.tools.nsc.typechecker.Typers$Typer.handlePolymorphicCall$1(Typers.scala:3841)
at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3846)
at scala.tools.nsc.typechecker.Typers$Typer.tryNamesDefaults$1(Typers.scala:3728)
at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3742)
at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:5095)
Stubbing the failure with !!!
t12461.scala:18: error: inferred type arguments [[A]T[A],S,!!!] do not conform to class Problem's type parameter bounds [T[A] <: X.Nasty[S,A],S,O]
Error occurred in an application involving default arguments.
new Problem(mark(position)) {
^
t12461.scala:18: error: type mismatch;
found : X.Problem[T(in class Problem),S(in class Problem),E]
required: X.Problem[(some other)T(in class Problem),(some other)S(in class Problem),O]
Error occurred in an application involving default arguments.
new Problem(mark(position)) {
^
t12461.scala:19: error: type mismatch;
found : X.Root{type A = S; type B = E}
required: X.Nasty[Nothing,Nothing]
(which expands to) X.Root{type A = Nothing; type B = Nothing}
override lazy val issue = Problem.this.issue.asInstanceOf[Nasty[S, E]]
^
t12461.scala:18: error: type mismatch;
found : X.Problem[Nothing,Nothing,Nothing]
required: X.Problem[T,S,E]
Note: Nothing <: T, but class Problem is invariant in type T.
You may wish to define T as +T instead. (SLS 4.5)
Note: Nothing <: S, but class Problem is invariant in type S.
You may wish to define S as +S instead. (SLS 4.5)
Note: Nothing <: E, but class Problem is invariant in type O.
You may wish to define O as +O instead. (SLS 4.5)
new Problem(mark(position)) {
^
using Scala 2.13.6
The issue is the copy method, combining type inference, higher types and default parameters. It is pretty close to minimal:
Nasty[_, O]
withProjectB[O]
fixes the issue;