Skip to content

Commit 9f9abfd

Browse files
oderskysmarter
authored andcommitted
Fix bug in GenericSignatures
1 parent e609851 commit 9f9abfd

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -1079,17 +1079,13 @@ object Types {
10791079
* @param checkClassInfo if true we check that ClassInfos are within bounds of abstract types
10801080
*/
10811081
final def overrides(that: Type, relaxedCheck: Boolean, matchLoosely: => Boolean, checkClassInfo: Boolean = true)(using Context): Boolean = {
1082-
def widenNullary(tp: Type) = tp match {
1083-
case tp @ MethodType(Nil) => tp.resultType
1084-
case _ => tp
1085-
}
10861082
val overrideCtx = if relaxedCheck then ctx.relaxedOverrideContext else ctx
10871083
inContext(overrideCtx) {
10881084
!checkClassInfo && this.isInstanceOf[ClassInfo]
10891085
|| (this.widenExpr frozen_<:< that.widenExpr)
10901086
|| matchLoosely && {
1091-
val this1 = widenNullary(this)
1092-
val that1 = widenNullary(that)
1087+
val this1 = this.widenNullaryMethod
1088+
val that1 = that.widenNullaryMethod
10931089
((this1 `ne` this) || (that1 `ne` that)) && this1.overrides(that1, relaxedCheck, false, checkClassInfo)
10941090
}
10951091
}
@@ -1326,6 +1322,11 @@ object Types {
13261322
this
13271323
}
13281324

1325+
/** If this is a nullary method type, its result type */
1326+
def widenNullaryMethod(using Context): Type = this match
1327+
case tp @ MethodType(Nil) => tp.resType
1328+
case _ => this
1329+
13291330
/** The singleton types that must or may be in this type. @see Atoms.
13301331
* Overridden and cached in OrType.
13311332
*/

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ object GenericSignatures {
189189
fullNameInSig(tp.typeSymbol)
190190
builder.append(';')
191191
case _ =>
192-
boxedSig(tp)
192+
boxedSig(tp.widenDealias.widenNullaryMethod)
193+
// `tp` might be a singleton type referring to a getter.
194+
// Hence the widenNullaryMethod.
193195
}
194196

195197
if (pre.exists) {

0 commit comments

Comments
 (0)