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
[PROOF-OF-CONCEPT] Avoid forcing type aliases to get their typeParams
This is a strawman proposal for fixing #970, before this commit, the
following fails with a cyclic reference error:
dotc B.scala\
./scala-scala/src/library/scala/collection/immutable/Seq.scala\
./scala-scala/src/library/scala/package.scala\
./scala-scala/src/library/scala/collection/GenSeqLike.scala\
./scala-scala/src/library/scala/collection/SeqLike.scala\
./scala-scala/src/library/scala/collection/generic/GenSeqFactory.scala
where B.scala is defined as:
object B{
def main(args: Array[String]): Unit = {
val s = List(1,2,3)
()
}
}
Here's what I think is happening:
1. Unpickling a Scala2 TypeRef requires us to perform type application.
(`Scala2Unpickler#readType`)
2. To apply a TypeAlias to some arguments, we first need to determine its
type parameters.
(`TypeApplications#appliedTo` and `TypeApplications#typeParams`)
3. To do this, we look at the type parameters of the underlying type of
the TypeAlias, this requires completing the TypeAlias.
4. If the TypeAlias is defined in a source tree and not unpickled, this
forces us to typecheck its right-hand side.
(`Namer#Completer#typeSig`)
5. In turns, this forces various classes to be completed, which might
themselves refer indirectly to type aliases, forcing even more
stuff.
This commit is a hacky way to avoid 3. by only completing the type parameters
of a type alias instead of completing the whole type alias when we don't
need it. Let me know if you think the basic idea is sound or not and if
you can think of a nicer way to implement it!
0 commit comments