Skip to content

Fix #2943: Insert LazyRefs automatically upon Unpickling #2956

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

Merged
merged 1 commit into from
Aug 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ Standard-Section: "ASTs" TopLevelStat*
BIND Length boundName_NameRef bounds_Type
// for type-variables defined in a type pattern
BYNAMEtype underlying_Type
LAZYref underlying_Type
POLYtype Length result_Type NamesTypes
METHODtype Length result_Type NamesTypes // needed for refinements
TYPELAMBDAtype Length result_Type NamesTypes // variance encoded in front of name: +/-/(nothing)
Expand Down Expand Up @@ -323,7 +322,6 @@ object TastyFormat {
final val PROTECTEDqualified = 105
final val RECtype = 106
final val SINGLETONtpt = 107
final val LAZYref = 108

final val IDENT = 112
final val IDENTtpt = 113
Expand Down Expand Up @@ -514,7 +512,6 @@ object TastyFormat {
case DOUBLEconst => "DOUBLEconst"
case STRINGconst => "STRINGconst"
case RECtype => "RECtype"
case LAZYref => "LAZYref"

case IDENT => "IDENT"
case IDENTtpt => "IDENTtpt"
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ class TreePickler(pickler: TastyPickler) {
case tpe: ParamRef =>
assert(pickleParamRef(tpe), s"orphan parameter reference: $tpe")
case tpe: LazyRef =>
writeByte(LAZYref)
pickleType(tpe.ref)
}

Expand Down
8 changes: 3 additions & 5 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package tasty
import Contexts._, Symbols._, Types._, Scopes._, SymDenotations._, Names._, NameOps._
import StdNames._, Denotations._, Flags._, Constants._, Annotations._
import NameKinds._
import typer.Checking.checkNonCyclic
import util.Positions._
import ast.{tpd, Trees, untpd}
import Trees._
Expand Down Expand Up @@ -293,10 +294,6 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
RecType(rt => registeringType(rt, readType()))
case RECthis =>
RecThis(readTypeRef().asInstanceOf[RecType])
case LAZYref =>
val rdr = fork
skipTree()
LazyRef(implicit ctx => rdr.readType())
case SHARED =>
val ref = readAddr()
typeAtAddr.getOrElseUpdate(ref, forkAt(ref).readType())
Expand Down Expand Up @@ -678,8 +675,9 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
TypeDef(readTemplate(localCtx))
} else {
val rhs = readTpt()
sym.info = NoCompleter
sym.info = rhs.tpe match {
case _: TypeBounds | _: ClassInfo => rhs.tpe
case _: TypeBounds | _: ClassInfo => checkNonCyclic(sym, rhs.tpe, reportErrors = false)
case _ => TypeAlias(rhs.tpe, sym.variance)
}
TypeDef(rhs)
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ object Checking {
}
if (isInteresting(pre)) {
val pre1 = this(pre, false, false)
if (locked.contains(tp)) throw CyclicReference(tp.symbol)
if (locked.contains(tp) || tp.symbol.infoOrCompleter == NoCompleter)
throw CyclicReference(tp.symbol)
locked += tp
try checkInfo(tp.info)
finally locked -= tp
Expand Down