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
Note: this is a New and Improved™ version of this issue after I discovered a much more precise description of the problem while trying to develop a temporary workaround. I edited the existing issue since it is still the exact same problem, hopefully that's ok.
// we need this to get something with a type member// and a corresponding implicitly unreachable but known Type nodeimportscala.quoted._traitTrait {
typetvaltType:Type[t]
}
objectO {
deffn[T](c : Trait) givenQuoteContext:Unit= c match {
case v => {
implicitval_:Type[v.t] = v.tType
typeVT= v.t
vala='[List[VT]]
()
}
}
}
This, as long as the '[...] is a non-trivial expression in terms of VT, crashes Dotty's codegen ('[VT] is fine, probably because it does not need to generate anything). This can be reproduced as long as v comes from a pattern match, and VT is derived from a type member of v. This includes implicit Type nodes generated by calling a function that takes Type[...VT...] as an implicit argument.
The crash can be avoided by explicitly writing out the type splices:
objectO {
deffn[T](c : Trait) :Unit= c match {
case v => {
implicitval_:Type[v.t] = v.tType
typeVT= v.t
valtp:Type[List[VT]] ='[List[${v.tType}]]
()
}
}
}
The error will look something like this:
java.util.NoSuchElementException: class Type
at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:437)
at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:436)
at scala.collection.mutable.AnyRefMap.apply(AnyRefMap.scala:192)
at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder$locals$.load(BCodeSkelBuilder.scala:396)
at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:392)
at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.emitNormalMethodBody$1(BCodeSkelBuilder.scala:
597)
at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:630)
at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:501)
at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen$$anonfun$1(BCodeSkelBuilder.scala:503)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:392)
at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:503)
at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:109)
at dotty.tools.backend.jvm.GenBCodePipeline$Worker1.visit(GenBCode.scala:213)
at dotty.tools.backend.jvm.GenBCodePipeline$Worker1.run(GenBCode.scala:180)
at dotty.tools.backend.jvm.GenBCodePipeline.buildAndSendToDisk(GenBCode.scala:510)
at dotty.tools.backend.jvm.GenBCodePipeline.run(GenBCode.scala:476)
at dotty.tools.backend.jvm.GenBCode.run(GenBCode.scala:54)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:313)
at scala.collection.immutable.List.map(List.scala:286)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:315)
at dotty.tools.backend.jvm.GenBCode.runOn(GenBCode.scala:59)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:102)
at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
at dotty.tools.dotc.Run.compileSources(Run.scala:120)
at dotty.tools.dotc.Run.compile(Run.scala:104)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:33)
at dotty.tools.dotc.Driver.process(Driver.scala:170)
at dotty.tools.dotc.Driver.process(Driver.scala:139)
at dotty.tools.dotc.Driver.process(Driver.scala:151)
at dotty.tools.dotc.Driver.main(Driver.scala:178)
at dotty.tools.dotc.Main.main(Main.scala)
Error while emitting Polyparse.scala
class Type
The text was updated successfully, but these errors were encountered:
fhackett
changed the title
Constructing a Type[(A,B)] can sometimes crash Dotty's codegen
Codegen crashes on implicit lookup of Type[T], where T is type member of variable from match case
Mar 23, 2019
Note: this is a New and Improved™ version of this issue after I discovered a much more precise description of the problem while trying to develop a temporary workaround. I edited the existing issue since it is still the exact same problem, hopefully that's ok.
This, as long as the
'[...]
is a non-trivial expression in terms ofVT
, crashes Dotty's codegen ('[VT]
is fine, probably because it does not need to generate anything). This can be reproduced as long asv
comes from a pattern match, andVT
is derived from a type member ofv
. This includes implicitType
nodes generated by calling a function that takesType[...VT...]
as an implicit argument.The crash can be avoided by explicitly writing out the type splices:
The error will look something like this:
The text was updated successfully, but these errors were encountered: