Skip to content

be more explicit when unpickling names, assert no rhs of PARAM #12858

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
Jun 21, 2021
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
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package core
package tasty

import dotty.tools.tasty.{TastyFormat, TastyBuffer, TastyReader, TastyHeaderUnpickler}
import TastyFormat.NameTags._
import TastyFormat.NameTags._, TastyFormat.nameTagToString
import TastyBuffer.NameRef

import scala.collection.mutable
Expand Down Expand Up @@ -79,8 +79,10 @@ class TastyUnpickler(reader: TastyReader) {
val original = readName()
val target = readName()
readSignedRest(original, target)
case _ =>
case SUPERACCESSOR | INLINEACCESSOR | BODYRETAINER | OBJECTCLASS =>
simpleNameKindOfTag(tag)(readName())
case _ =>
throw MatchError(s"unknown name tag ${nameTagToString(tag)}")
}
assert(currentAddr == end, s"bad name $result $start $currentAddr $end")
result
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ class TreePickler(pickler: TastyPickler) {
def pickleParam(tree: Tree)(using Context): Unit = {
registerTreeAddr(tree)
tree match {
case tree: ValDef => pickleDef(PARAM, tree, tree.tpt)
case tree: DefDef => pickleDef(PARAM, tree, tree.tpt, tree.rhs)
case tree: ValDef => pickleDef(PARAM, tree, tree.tpt)
case tree: TypeDef => pickleDef(TYPEPARAM, tree, tree.rhs)
}
}
Expand Down
12 changes: 3 additions & 9 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -873,15 +873,9 @@ class TreeUnpickler(reader: TastyReader,
}
case PARAM =>
val tpt = readTpt()(using localCtx)
if (nothingButMods(end)) {
sym.info = tpt.tpe
ValDef(tpt)
}
else {
sym.info = ExprType(tpt.tpe)
pickling.println(i"reading param alias $name -> $currentAddr")
DefDef(Nil, tpt)
}
assert(nothingButMods(end))
sym.info = tpt.tpe
ValDef(tpt)
}
goto(end)
setSpan(start, tree)
Expand Down
2 changes: 1 addition & 1 deletion tasty/src/dotty/tools/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Standard-Section: "ASTs" TopLevelStat*
BOUNDED type_Term -- type bound

TypeParam = TYPEPARAM Length NameRef type_Term Modifier* -- modifiers name bounds
TermParam = PARAM Length NameRef type_Term rhs_Term? Modifier* -- modifiers name : type (= rhs_Term)?. `rhsTerm` is present in the case of an aliased class parameter
TermParam = PARAM Length NameRef type_Term Modifier* -- modifiers name : type.
EMPTYCLAUSE -- an empty parameter clause ()
SPLITCLAUSE -- splits two non-empty parameter clauses of the same kind
Param = TypeParam
Expand Down