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
crash with inferred type: "T in class Class cannot be instantiated" #4305
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4305?orig=1 |
@paulp said: % scalac29 `find /scala/trunk/src/library/scala/collection -name '*.scala'`
error: java.lang.Error: A in trait TraversableViewLike cannot be instantiated from [+A,+Coll,+This <: scala.collection.TraversableView[A,Coll] with scala.collection.TraversableViewLike[A,Coll,This]]scala.collection.TraversableViewLike[A,Coll,This]
at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:35)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.throwError$$1(Types.scala:3389)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.instParam$$1(Types.scala:3392)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.toInstance$$1(Types.scala:3403)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:3419)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:3289)
at scala.tools.nsc.symtab.Types$$TypeMap$$$$anonfun$$mapOverArgs$$1.apply(Types.scala:3114)
at scala.tools.nsc.symtab.Types$$TypeMap$$$$anonfun$$mapOverArgs$$1.apply(Types.scala:3110)
at scala.tools.nsc.symtab.Types$$class.map2Conserve(Types.scala:4886)
at scala.tools.nsc.symtab.SymbolTable.map2Conserve(SymbolTable.scala:13) |
@paulp said: # compiles this way
% scalac29 src/library/scala/collection/SeqViewLike.scala src/library/scala/collection/immutable/StreamViewLike.scala
# not this way
% scalac29 src/library/scala/collection/immutable/StreamViewLike.scala src/library/scala/collection/SeqViewLike.scala
error: java.lang.Error: A in trait TraversableViewLike cannot be instantiated from [+A,+Coll,+This <: scala.collection.TraversableView[A,Coll] with scala.collection.TraversableViewLike[A,Coll,This]]scala.collection.TraversableViewLike[A,Coll,This]
at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:35)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.throwError$$1(Types.scala:3389)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.instParam$$1(Types.scala:3392)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.toInstance$$1(Types.scala:3403)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:3419)
at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:3289)
at scala.tools.nsc.symtab.Types$$TypeMap$$$$anonfun$$mapOverArgs$$1.apply(Types.scala:3114) I am going to kick this up to high for now because these source file order dependent bugs are maddening so if something can be done in the short term it would be great, but if someone wants to de-high it I won't complain. |
@adriaanm said: a stopgap fix could be to add a sym.info in a strategic location, but I'm not sure we should be doing that right now -- in any case, I'd prefer to delay working on this until I can fix it properly |
@adriaanm said:
|
@paulp said: |
@adriaanm said: the compilation order dependent problem with collections can be reduced to (minimally): // 1.scala
trait Derived[+SA, +This <: Derived[SA, This]] extends Base[SA, This] {
trait Reversed extends super.Reversed with super.Transformed[SA]
protected override def newReversed: super.Transformed[SA] = new Reversed { }
} // 2.scala
trait Base[+A, +This <: Base[A, This]] {
trait Transformed[+B] {
override def toString: String = error("")
}
trait Reversed extends Transformed[A] {
private def x: Unit = {x: A => error("") }
}
protected def newReversed: Transformed[A] = new Reversed { }
} |
@adriaanm said:
so the question is: why is baseType returning a PolyType here!? |
@adriaanm said: since the error occurs late in the game and generic signatures are not absolutely crucial, I'd suggest a temporary cop out: catch the exception thrown by memberInfo in addGenericSignature in GenJVM test cases and "fix" that makes me cringe in commit adriaanm/scala@1cac127 Paul, could you please take it from here? |
@paulp said:
You got it. Thanks for giving us a whole day of your precious time! (I'm just kidding, your time's not that precious.) |
This worked in 2.7, and crashes the compiler from 2.8.0 through current trunk.
The following variation does not crash 2.8.0 or 2.8.1, but still crashes current trunk.
Finally, this variation doesn't crash anyone.
The crash looks like:
The text was updated successfully, but these errors were encountered: