Skip to content

Commit 8f6ce4b

Browse files
committed
Make companionModule more robust.
I witnessd a MatchError crash when fooling around with implicits, which is fixed by this change.
1 parent bc39a01 commit 8f6ce4b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,13 +1001,14 @@ object SymDenotations {
10011001
final def companionModule(implicit ctx: Context): Symbol =
10021002
if (is(Module)) sourceModule
10031003
else if (isOpaqueAlias) {
1004-
def reference(tp: Type): TermRef = tp match {
1005-
case TypeRef(prefix: TermRef, _) => prefix
1004+
def reference(tp: Type): Symbol = tp match {
1005+
case TypeRef(prefix: TermRef, _) => prefix.termSymbol
10061006
case tp: HKTypeLambda => reference(tp.resType)
10071007
case tp: AppliedType => reference(tp.tycon)
1008+
case tp: ErrorType => registeredCompanion.sourceModule
10081009
}
10091010
val TypeAlias(alias) = info
1010-
reference(alias).termSymbol
1011+
reference(alias)
10111012
}
10121013
else registeredCompanion.sourceModule
10131014

0 commit comments

Comments
 (0)