Skip to content

Commit

Permalink
Work around scala/scala3#19237
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjrd committed Dec 18, 2023
1 parent d44af7b commit 6200185
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6200185

Please sign in to comment.