Skip to content

Commit 406df2a

Browse files
committed
Make sure signatures are computed before erasure
Some symbols change their signatures after erasure, e.g. getters with Unit type or constructors taking an outer parameter. Since signatures are assumed to be stable for a complete run, we need to always compute signatures for NamedTypes before ersure.
1 parent 5f2f66a commit 406df2a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,29 +1890,31 @@ object Types {
18901890
}
18911891

18921892
/** The signature of the last known denotation, or if there is none, the
1893-
* signature of the symbol
1893+
* signature of the symbol. Signatures are always computed before erasure, since
1894+
* some symbols change their signature at erasure.
18941895
*/
1895-
protected def computeSignature(implicit ctx: Context): Signature = {
1896+
protected def computeSignature(implicit ctx: Context): Signature =
18961897
val lastd = lastDenotation
1897-
if (lastd != null) lastd.signature
1898+
val isErased = ctx.erasedTypes
1899+
if lastd != null && !isErased then lastd.signature
1900+
else if isErased then computeSignature(using ctx.withPhase(ctx.erasurePhase))
18981901
else symbol.asSeenFrom(prefix).signature
1899-
}
19001902

19011903
/** The signature of the current denotation if it is known without forcing.
19021904
* Otherwise the signature of the current symbol if it is known without forcing.
19031905
* Otherwise NotAMethod.
19041906
*/
19051907
private def currentSignature(implicit ctx: Context): Signature =
1906-
if (ctx.runId == mySignatureRunId) mySignature
1907-
else {
1908+
if ctx.runId == mySignatureRunId then mySignature
1909+
else
19081910
val lastd = lastDenotation
1909-
if (lastd != null) lastd.signature
1910-
else {
1911+
val isErased = ctx.erasedTypes
1912+
if lastd != null && !isErased then lastd.signature
1913+
else if isErased then currentSignature(using ctx.withPhase(ctx.erasurePhase))
1914+
else
19111915
val sym = currentSymbol
1912-
if (sym.exists) sym.asSeenFrom(prefix).signature
1916+
if sym.exists then sym.asSeenFrom(prefix).signature
19131917
else Signature.NotAMethod
1914-
}
1915-
}
19161918

19171919
final def symbol(implicit ctx: Context): Symbol =
19181920
// We can rely on checkedPeriod (unlike in the definition of `denot` below)

0 commit comments

Comments
 (0)