Skip to content

Commit ab40a6e

Browse files
committed
Fix signature computation again
1 parent 54a8539 commit ab40a6e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,31 +1889,40 @@ object Types {
18891889
case sym: Symbol => sym.originDenotation.name
18901890
}
18911891

1892-
/** The signature of the last known denotation, or if there is none, the
1893-
* signature of the symbol. Signatures are always computed before erasure, since
1894-
* some symbols change their signature at erasure.
1892+
/** The signature computed from the last known denotation with `sigFromDenot`,
1893+
* or if there is none, the signature of the symbol. Signatures are always
1894+
* computed before erasure, since some symbols change their signature at erasure.
18951895
*/
18961896
protected def computeSignature(implicit ctx: Context): Signature =
18971897
val lastd = lastDenotation
1898-
if lastd != null && lastd.validFor.firstPhaseId <= ctx.erasurePhase.id then lastd.signature
1898+
if lastd != null then sigFromDenot(lastd)
18991899
else if ctx.erasedTypes then computeSignature(using ctx.withPhase(ctx.erasurePhase))
19001900
else symbol.asSeenFrom(prefix).signature
19011901

1902-
/** The signature of the current denotation if it is known without forcing.
1902+
/** The signature computed from the current denotation with `sigFromDenot` if it is
1903+
* known without forcing.
19031904
* Otherwise the signature of the current symbol if it is known without forcing.
1904-
* Otherwise NotAMethod.
1905+
* Otherwise NotAMethod. Signatures are always computed before erasure, since
1906+
* some symbols change their signature at erasure.
19051907
*/
19061908
private def currentSignature(implicit ctx: Context): Signature =
19071909
if ctx.runId == mySignatureRunId then mySignature
19081910
else
19091911
val lastd = lastDenotation
1910-
if lastd != null && lastd.validFor.firstPhaseId <= ctx.erasurePhase.id then lastd.signature
1912+
if lastd != null then sigFromDenot(lastd)
19111913
else if ctx.erasedTypes then currentSignature(using ctx.withPhase(ctx.erasurePhase))
19121914
else
19131915
val sym = currentSymbol
19141916
if sym.exists then sym.asSeenFrom(prefix).signature
19151917
else Signature.NotAMethod
19161918

1919+
/** The signature of a pre-erasure version of denotation `lastd`. */
1920+
private def sigFromDenot(lastd: Denotation)(using Context) =
1921+
if lastd.validFor.firstPhaseId <= ctx.erasurePhase.id then lastd.signature
1922+
else lastd match
1923+
case lastd: SingleDenotation => lastd.initial.signature
1924+
case _ => Signature.OverloadedSignature
1925+
19171926
final def symbol(implicit ctx: Context): Symbol =
19181927
// We can rely on checkedPeriod (unlike in the definition of `denot` below)
19191928
// because SymDenotation#installAfter never changes the symbol

0 commit comments

Comments
 (0)