Skip to content

Commit 79d9949

Browse files
oderskysmarter
authored andcommitted
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 38272aa commit 79d9949

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
@@ -1897,29 +1897,31 @@ object Types {
18971897
}
18981898

18991899
/** The signature of the last known denotation, or if there is none, the
1900-
* signature of the symbol
1900+
* signature of the symbol. Signatures are always computed before erasure, since
1901+
* some symbols change their signature at erasure.
19011902
*/
1902-
protected def computeSignature(implicit ctx: Context): Signature = {
1903+
protected def computeSignature(implicit ctx: Context): Signature =
19031904
val lastd = lastDenotation
1904-
if (lastd != null) lastd.signature
1905+
val isErased = ctx.erasedTypes
1906+
if lastd != null && !isErased then lastd.signature
1907+
else if isErased then computeSignature(using ctx.withPhase(ctx.erasurePhase))
19051908
else symbol.asSeenFrom(prefix).signature
1906-
}
19071909

19081910
/** The signature of the current denotation if it is known without forcing.
19091911
* Otherwise the signature of the current symbol if it is known without forcing.
19101912
* Otherwise NotAMethod.
19111913
*/
19121914
private def currentSignature(implicit ctx: Context): Signature =
1913-
if (ctx.runId == mySignatureRunId) mySignature
1914-
else {
1915+
if ctx.runId == mySignatureRunId then mySignature
1916+
else
19151917
val lastd = lastDenotation
1916-
if (lastd != null) lastd.signature
1917-
else {
1918+
val isErased = ctx.erasedTypes
1919+
if lastd != null && !isErased then lastd.signature
1920+
else if isErased then currentSignature(using ctx.withPhase(ctx.erasurePhase))
1921+
else
19181922
val sym = currentSymbol
1919-
if (sym.exists) sym.asSeenFrom(prefix).signature
1923+
if sym.exists then sym.asSeenFrom(prefix).signature
19201924
else Signature.NotAMethod
1921-
}
1922-
}
19231925

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

0 commit comments

Comments
 (0)