Skip to content

Commit 0e6d670

Browse files
oderskysmarter
authored andcommitted
Fix signature computation again
1 parent cbfead3 commit 0e6d670

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
@@ -1896,31 +1896,40 @@ object Types {
18961896
case sym: Symbol => sym.originDenotation.name
18971897
}
18981898

1899-
/** The signature of the last known denotation, or if there is none, the
1900-
* signature of the symbol. Signatures are always computed before erasure, since
1901-
* some symbols change their signature at erasure.
1899+
/** The signature computed from the last known denotation with `sigFromDenot`,
1900+
* or if there is none, the signature of the symbol. Signatures are always
1901+
* computed before erasure, since some symbols change their signature at erasure.
19021902
*/
19031903
protected def computeSignature(implicit ctx: Context): Signature =
19041904
val lastd = lastDenotation
1905-
if lastd != null && lastd.validFor.firstPhaseId <= ctx.erasurePhase.id then lastd.signature
1905+
if lastd != null then sigFromDenot(lastd)
19061906
else if ctx.erasedTypes then computeSignature(using ctx.withPhase(ctx.erasurePhase))
19071907
else symbol.asSeenFrom(prefix).signature
19081908

1909-
/** The signature of the current denotation if it is known without forcing.
1909+
/** The signature computed from the current denotation with `sigFromDenot` if it is
1910+
* known without forcing.
19101911
* Otherwise the signature of the current symbol if it is known without forcing.
1911-
* Otherwise NotAMethod.
1912+
* Otherwise NotAMethod. Signatures are always computed before erasure, since
1913+
* some symbols change their signature at erasure.
19121914
*/
19131915
private def currentSignature(implicit ctx: Context): Signature =
19141916
if ctx.runId == mySignatureRunId then mySignature
19151917
else
19161918
val lastd = lastDenotation
1917-
if lastd != null && lastd.validFor.firstPhaseId <= ctx.erasurePhase.id then lastd.signature
1919+
if lastd != null then sigFromDenot(lastd)
19181920
else if ctx.erasedTypes then currentSignature(using ctx.withPhase(ctx.erasurePhase))
19191921
else
19201922
val sym = currentSymbol
19211923
if sym.exists then sym.asSeenFrom(prefix).signature
19221924
else Signature.NotAMethod
19231925

1926+
/** The signature of a pre-erasure version of denotation `lastd`. */
1927+
private def sigFromDenot(lastd: Denotation)(using Context) =
1928+
if lastd.validFor.firstPhaseId <= ctx.erasurePhase.id then lastd.signature
1929+
else lastd match
1930+
case lastd: SingleDenotation => lastd.initial.signature
1931+
case _ => Signature.OverloadedSignature
1932+
19241933
final def symbol(implicit ctx: Context): Symbol =
19251934
// We can rely on checkedPeriod (unlike in the definition of `denot` below)
19261935
// because SymDenotation#installAfter never changes the symbol

0 commit comments

Comments
 (0)