Skip to content

Commit c5f4e47

Browse files
authored
Merge pull request #2956 from dotty-staging/fix-#2943
Fix #2943: Insert LazyRefs automatically upon Unpickling
2 parents 0174308 + 43f2cc5 commit c5f4e47

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ Standard-Section: "ASTs" TopLevelStat*
164164
BIND Length boundName_NameRef bounds_Type
165165
// for type-variables defined in a type pattern
166166
BYNAMEtype underlying_Type
167-
LAZYref underlying_Type
168167
POLYtype Length result_Type NamesTypes
169168
METHODtype Length result_Type NamesTypes // needed for refinements
170169
TYPELAMBDAtype Length result_Type NamesTypes // variance encoded in front of name: +/-/(nothing)
@@ -323,7 +322,6 @@ object TastyFormat {
323322
final val PROTECTEDqualified = 105
324323
final val RECtype = 106
325324
final val SINGLETONtpt = 107
326-
final val LAZYref = 108
327325

328326
final val IDENT = 112
329327
final val IDENTtpt = 113
@@ -514,7 +512,6 @@ object TastyFormat {
514512
case DOUBLEconst => "DOUBLEconst"
515513
case STRINGconst => "STRINGconst"
516514
case RECtype => "RECtype"
517-
case LAZYref => "LAZYref"
518515

519516
case IDENT => "IDENT"
520517
case IDENTtpt => "IDENTtpt"

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ class TreePickler(pickler: TastyPickler) {
246246
case tpe: ParamRef =>
247247
assert(pickleParamRef(tpe), s"orphan parameter reference: $tpe")
248248
case tpe: LazyRef =>
249-
writeByte(LAZYref)
250249
pickleType(tpe.ref)
251250
}
252251

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package tasty
66
import Contexts._, Symbols._, Types._, Scopes._, SymDenotations._, Names._, NameOps._
77
import StdNames._, Denotations._, Flags._, Constants._, Annotations._
88
import NameKinds._
9+
import typer.Checking.checkNonCyclic
910
import util.Positions._
1011
import ast.{tpd, Trees, untpd}
1112
import Trees._
@@ -293,10 +294,6 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
293294
RecType(rt => registeringType(rt, readType()))
294295
case RECthis =>
295296
RecThis(readTypeRef().asInstanceOf[RecType])
296-
case LAZYref =>
297-
val rdr = fork
298-
skipTree()
299-
LazyRef(implicit ctx => rdr.readType())
300297
case SHARED =>
301298
val ref = readAddr()
302299
typeAtAddr.getOrElseUpdate(ref, forkAt(ref).readType())
@@ -678,8 +675,9 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
678675
TypeDef(readTemplate(localCtx))
679676
} else {
680677
val rhs = readTpt()
678+
sym.info = NoCompleter
681679
sym.info = rhs.tpe match {
682-
case _: TypeBounds | _: ClassInfo => rhs.tpe
680+
case _: TypeBounds | _: ClassInfo => checkNonCyclic(sym, rhs.tpe, reportErrors = false)
683681
case _ => TypeAlias(rhs.tpe, sym.variance)
684682
}
685683
TypeDef(rhs)

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ object Checking {
239239
}
240240
if (isInteresting(pre)) {
241241
val pre1 = this(pre, false, false)
242-
if (locked.contains(tp)) throw CyclicReference(tp.symbol)
242+
if (locked.contains(tp) || tp.symbol.infoOrCompleter == NoCompleter)
243+
throw CyclicReference(tp.symbol)
243244
locked += tp
244245
try checkInfo(tp.info)
245246
finally locked -= tp

0 commit comments

Comments
 (0)