@@ -1896,30 +1896,39 @@ 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
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.
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+ if lastd != null then sigFromDenot(lastd)
1906+ else if ctx.erasedTypes then computeSignature(using ctx.withPhase(ctx.erasurePhase))
19051907 else symbol.asSeenFrom(prefix).signature
1906- }
19071908
1908- /** 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.
19091911 * Otherwise the signature of the current symbol if it is known without forcing.
1910- * Otherwise NotAMethod.
1912+ * Otherwise NotAMethod. Signatures are always computed before erasure, since
1913+ * some symbols change their signature at erasure.
19111914 */
19121915 private def currentSignature (implicit ctx : Context ): Signature =
1913- if ( ctx.runId == mySignatureRunId) mySignature
1914- else {
1916+ if ctx.runId == mySignatureRunId then mySignature
1917+ else
19151918 val lastd = lastDenotation
1916- if (lastd != null ) lastd.signature
1917- else {
1919+ if lastd != null then sigFromDenot(lastd)
1920+ else if ctx.erasedTypes 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- }
1925+
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
19231932
19241933 final def symbol (implicit ctx : Context ): Symbol =
19251934 // We can rely on checkedPeriod (unlike in the definition of `denot` below)
@@ -3066,7 +3075,7 @@ object Types {
30663075 }
30673076 }
30683077
3069- trait MethodicType extends SignatureCachingType {
3078+ trait MethodicType extends TermType {
30703079 protected def resultSignature (implicit ctx : Context ): Signature = try resultType match {
30713080 case rtp : MethodicType => rtp.signature
30723081 case tp =>
@@ -3086,7 +3095,7 @@ object Types {
30863095 override def resultType (implicit ctx : Context ): Type = resType
30873096 override def underlying (implicit ctx : Context ): Type = resType
30883097
3089- def computeSignature (implicit ctx : Context ): Signature = resultSignature
3098+ override def signature (implicit ctx : Context ): Signature = Signature . NotAMethod
30903099
30913100 def derivedExprType (resType : Type )(implicit ctx : Context ): ExprType =
30923101 if (resType eq this .resType) this else ExprType (resType)
@@ -3192,7 +3201,7 @@ object Types {
31923201 final override def equals (that : Any ): Boolean = equals(that, null )
31933202 }
31943203
3195- abstract class MethodOrPoly extends UncachedGroundType with LambdaType with MethodicType {
3204+ abstract class MethodOrPoly extends UncachedGroundType with LambdaType with MethodicType with SignatureCachingType {
31963205 final override def hashCode : Int = System .identityHashCode(this )
31973206
31983207 final override def equals (that : Any ): Boolean = equals(that, null )
0 commit comments