Skip to content

Commit 9de9c4d

Browse files
authored
Merge pull request #7101 from dotty-staging/fix-#6989
Fix #6989: Make sure scalacLinkedClass finds companion when unpickling
2 parents c3233d2 + c74f710 commit 9de9c4d

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ class TreeUnpickler(reader: TastyReader,
801801
ValDef(tpt)
802802
case TYPEDEF | TYPEPARAM =>
803803
if (sym.isClass) {
804+
sym.owner.ensureCompleted() // scalacLinkedClass uses unforcedDecls. Make sure it does not miss anything.
804805
val companion = sym.scalacLinkedClass
805806

806807
// Is the companion defined in the same Tasty file as `sym`?

tests/pos/i6989/Container_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package mypkg
2+
3+
object Container {
4+
class StringExtras(val s: String) extends AnyVal {
5+
def op(item: Int): Int = ???
6+
}
7+
}
8+
9+
trait Container {
10+
import Container._
11+
implicit def mkStringExtras(s: String): StringExtras = new StringExtras(s)
12+
}

tests/pos/i6989/SimpleTest_2.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package mypkg
2+
3+
class SimpleTest extends Container {
4+
"foo".op(5)
5+
}

0 commit comments

Comments
 (0)