Skip to content

Commit 32c93e4

Browse files
committed
Handle SingleDenotations in ExtensionMethods
The missing case was discovered while experimenting with different opaque type encodings. It has nothing to do with opaque types, just with the fact that we sometimes got a UniqueRefDenotation instead of a SymDenotation. But this should not make a difference.
1 parent 2adc617 commit 32c93e4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,16 @@ class ExtensionMethods extends MiniPhase with DenotTransformer with FullParamete
113113
}
114114
ref1
115115
case _ =>
116-
ref
116+
ref.info match {
117+
case ClassInfo(pre, cls, _, _, _) if cls is ModuleClass =>
118+
cls.linkedClass match {
119+
case valueClass: ClassSymbol if isDerivedValueClass(valueClass) =>
120+
val info1 = cls.denot(ctx.withPhase(ctx.phase.next)).asClass.classInfo.derivedClassInfo(prefix = pre)
121+
ref.derivedSingleDenotation(ref.symbol, info1)
122+
case _ => ref
123+
}
124+
case _ => ref
125+
}
117126
}
118127

119128
protected def rewiredTarget(target: Symbol, derived: Symbol)(implicit ctx: Context): Symbol =
@@ -210,13 +219,14 @@ object ExtensionMethods {
210219
def extensionMethod(imeth: Symbol)(implicit ctx: Context): TermSymbol =
211220
ctx.atPhase(ctx.extensionMethodsPhase.next) { implicit ctx =>
212221
// FIXME use toStatic instead?
213-
val companionInfo = imeth.owner.companionModule.info
222+
val companion = imeth.owner.companionModule
223+
val companionInfo = companion.info
214224
val candidates = extensionNames(imeth) map (companionInfo.decl(_).symbol) filter (_.exists)
215225
val matching = candidates filter (c => FullParameterization.memberSignature(c.info) == imeth.signature)
216226
assert(matching.nonEmpty,
217227
i"""no extension method found for:
218228
|
219-
| $imeth:${imeth.info.show} with signature ${imeth.signature}
229+
| $imeth:${imeth.info.show} with signature ${imeth.signature} in ${companion.moduleClass}
220230
|
221231
| Candidates:
222232
|

0 commit comments

Comments
 (0)