Skip to content

Commit 50d6967

Browse files
authored
Merge pull request #12858 from dotty-staging/tasty/remove-param-rhs
be more explicit when unpickling names, assert no rhs of PARAM
2 parents 81c8e83 + 3cb6155 commit 50d6967

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package core
33
package tasty
44

55
import dotty.tools.tasty.{TastyFormat, TastyBuffer, TastyReader, TastyHeaderUnpickler}
6-
import TastyFormat.NameTags._
6+
import TastyFormat.NameTags._, TastyFormat.nameTagToString
77
import TastyBuffer.NameRef
88

99
import scala.collection.mutable
@@ -79,8 +79,10 @@ class TastyUnpickler(reader: TastyReader) {
7979
val original = readName()
8080
val target = readName()
8181
readSignedRest(original, target)
82-
case _ =>
82+
case SUPERACCESSOR | INLINEACCESSOR | BODYRETAINER | OBJECTCLASS =>
8383
simpleNameKindOfTag(tag)(readName())
84+
case _ =>
85+
throw MatchError(s"unknown name tag ${nameTagToString(tag)}")
8486
}
8587
assert(currentAddr == end, s"bad name $result $start $currentAddr $end")
8688
result

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ class TreePickler(pickler: TastyPickler) {
356356
def pickleParam(tree: Tree)(using Context): Unit = {
357357
registerTreeAddr(tree)
358358
tree match {
359-
case tree: ValDef => pickleDef(PARAM, tree, tree.tpt)
360-
case tree: DefDef => pickleDef(PARAM, tree, tree.tpt, tree.rhs)
359+
case tree: ValDef => pickleDef(PARAM, tree, tree.tpt)
361360
case tree: TypeDef => pickleDef(TYPEPARAM, tree, tree.rhs)
362361
}
363362
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -873,15 +873,9 @@ class TreeUnpickler(reader: TastyReader,
873873
}
874874
case PARAM =>
875875
val tpt = readTpt()(using localCtx)
876-
if (nothingButMods(end)) {
877-
sym.info = tpt.tpe
878-
ValDef(tpt)
879-
}
880-
else {
881-
sym.info = ExprType(tpt.tpe)
882-
pickling.println(i"reading param alias $name -> $currentAddr")
883-
DefDef(Nil, tpt)
884-
}
876+
assert(nothingButMods(end))
877+
sym.info = tpt.tpe
878+
ValDef(tpt)
885879
}
886880
goto(end)
887881
setSpan(start, tree)

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Standard-Section: "ASTs" TopLevelStat*
7070
BOUNDED type_Term -- type bound
7171
7272
TypeParam = TYPEPARAM Length NameRef type_Term Modifier* -- modifiers name bounds
73-
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
73+
TermParam = PARAM Length NameRef type_Term Modifier* -- modifiers name : type.
7474
EMPTYCLAUSE -- an empty parameter clause ()
7575
SPLITCLAUSE -- splits two non-empty parameter clauses of the same kind
7676
Param = TypeParam

0 commit comments

Comments
 (0)