Skip to content

Commit 6b1f7b8

Browse files
committed
Drop OBJECTDEF from TastyFormat
It was not supported yet by pickler and unpickler. In fact it would be quite awkward to support it since in the pickling format a symbol reference is the address of the definition tree node. So if there is only a single OBJECTDEF node, we get an ambiguity between object and its module class. This makes tree unpickling much harder. So I believe it is better to expose the object encoding into a lazy val and a class definition. That also explains where OBJECTNAMEs are bound.
1 parent b59cd4c commit 6b1f7b8

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ Standard-Section: "ASTs" TopLevelStat*
5757
Stat = Term
5858
ValOrDefDef
5959
TYPEDEF Length NameRef (type_Term | Template) Modifier* -- modifiers type name (= type | bounds) | moifiers class name template
60-
OBJECTDEF Length NameRef Template Modifier* -- modifiers object name template
6160
IMPORT Length [IMPLIED] qual_Term Selector* -- import implied? qual selectors
6261
ValOrDefDef = VALDEF Length NameRef type_Term rhs_Term? Modifier* -- modifiers val name : type (= rhs)?
6362
DEFDEF Length NameRef TypeParam* Params* returnType_Term rhs_Term?
@@ -430,7 +429,6 @@ object TastyFormat {
430429
final val ANNOTATION = 173
431430
final val TERMREFin = 174
432431
final val TYPEREFin = 175
433-
final val OBJECTDEF = 176
434432

435433
final val METHODtype = 180
436434
final val ERASEDMETHODtype = 181
@@ -593,7 +591,6 @@ object TastyFormat {
593591
case VALDEF => "VALDEF"
594592
case DEFDEF => "DEFDEF"
595593
case TYPEDEF => "TYPEDEF"
596-
case OBJECTDEF => "OBJECTDEF"
597594
case IMPORT => "IMPORT"
598595
case TYPEPARAM => "TYPEPARAM"
599596
case PARAMS => "PARAMS"
@@ -669,7 +666,7 @@ object TastyFormat {
669666
* If negative, minus the number of leading non-reference trees.
670667
*/
671668
def numRefs(tag: Int): Int = tag match {
672-
case VALDEF | DEFDEF | TYPEDEF | OBJECTDEF | TYPEPARAM | PARAM | NAMEDARG | RETURN | BIND |
669+
case VALDEF | DEFDEF | TYPEDEF | TYPEPARAM | PARAM | NAMEDARG | RETURN | BIND |
673670
SELFDEF | REFINEDtype | TERMREFin | TYPEREFin | HOLE => 1
674671
case RENAMED | PARAMtype => 2
675672
case POLYtype | TYPELAMBDAtype |

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
7878
tag match {
7979
case RENAMED =>
8080
printName(); printName()
81-
case VALDEF | DEFDEF | TYPEDEF | OBJECTDEF | TYPEPARAM | PARAM | NAMEDARG | BIND =>
81+
case VALDEF | DEFDEF | TYPEDEF | TYPEPARAM | PARAM | NAMEDARG | BIND =>
8282
printName(); printTrees()
8383
case REFINEDtype | TERMREFin | TYPEREFin =>
8484
printName(); printTree(); printTrees()
8585
case RETURN | HOLE =>
8686
printNat(); printTrees()
8787
case METHODtype | ERASEDMETHODtype |
88-
CONTEXTUALMETHODtype | ERASEDCONTEXTUALMETHODtype |
89-
IMPLICITMETHODtype | POLYtype | TYPELAMBDAtype =>
88+
GIVENMETHODtype | ERASEDGIVENMETHODtype | IMPLICITMETHODtype |
89+
POLYtype | TYPELAMBDAtype =>
9090
printTree()
9191
until(end) { printName(); printTree() }
9292
case PARAMtype =>

0 commit comments

Comments
 (0)