From 62001852726dc79c7e0f9fc91f963290d68867d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Mon, 18 Dec 2023 10:47:04 +0100 Subject: [PATCH] Work around https://github.com/lampepfl/dotty/issues/19237 It does not seem that the upstream issue will be fixed any time soon due to binary compatibility concerns. Nevertheless, it makes no sense, and it is not possible possible to create a *value* of a "package type". Therefore, we work around the issue by tolerating a `PackageRef` as the type of a PARAM of an inline accessor method. We replace it by `Nothing`, which matches the fact that no value can be created for it. Note that the *signature* and therefore the *signed name* of such a method will be different from what dotc computes, so it will still be semantically broken. --- .../tastyquery/reader/tasties/TreeUnpickler.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tasty-query/shared/src/main/scala/tastyquery/reader/tasties/TreeUnpickler.scala b/tasty-query/shared/src/main/scala/tastyquery/reader/tasties/TreeUnpickler.scala index 6409ef61..494be3cd 100644 --- a/tasty-query/shared/src/main/scala/tastyquery/reader/tasties/TreeUnpickler.scala +++ b/tasty-query/shared/src/main/scala/tastyquery/reader/tasties/TreeUnpickler.scala @@ -759,10 +759,19 @@ private[tasties] class TreeUnpickler private ( else if tag == VALDEF then Some(readTermOrUninitialized()) else Some(readTerm) readAnnotationsInModifiers(symbol, end) + tag match { case VALDEF | PARAM => - symbol.withDeclaredType(tpt.toType) + val tpe: Type = tpt.toPrefix match + case tpe: Type => + tpe + case packageRef: PackageRef => + // Work around https://github.com/lampepfl/dotty/issues/19237 + if tag == PARAM && symbol.owner.name.isInstanceOf[InlineAccessorName] then rctx.NothingType + else throw TastyFormatException(s"unexpected type $packageRef for $symbol in $posErrorMsg") + symbol.withDeclaredType(tpe) definingTree(symbol, ValDef(name, tpt, rhs, symbol)(spn)) + case DEFDEF => val normalizedParams = if name == nme.Constructor then normalizeCtorParamClauses(params)