Skip to content

Commit 8c0c461

Browse files
authored
Merge pull request #10912 from dotty-staging/fix-#10542
Fixes to TreeTypeMap and symbol copying
2 parents a90886d + 20a4652 commit 8c0c461

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package ast
44

55
import core._
66
import Types._, Contexts._
7-
import Symbols._, Annotations._, Trees._, Symbols._
7+
import Symbols._, Annotations._, Trees._, Symbols._, Constants.Constant
88
import Decorators._
99
import dotty.tools.dotc.transform.SymUtils._
1010
import core.tasty.TreePickler.Hole
@@ -124,6 +124,8 @@ class TreeTypeMap(
124124
cpy.Labeled(labeled)(bind1, expr1)
125125
case Hole(isTermHole, n, args) =>
126126
Hole(isTermHole, n, args.mapConserve(transform)).withSpan(tree.span).withType(mapType(tree.tpe))
127+
case lit @ Literal(Constant(tpe: Type)) =>
128+
cpy.Literal(lit)(Constant(mapType(tpe)))
127129
case tree1 =>
128130
super.transform(tree1)
129131
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,10 @@ object Symbols {
835835
info = completer,
836836
privateWithin = ttmap1.mapOwner(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here.
837837
annotations = odenot.annotations)
838-
copy.registeredCompanion =
839-
copy.registeredCompanion.subst(originals, copies)
838+
copy.denot match
839+
case cd: ClassDenotation =>
840+
cd.registeredCompanion = cd.unforcedRegisteredCompanion.subst(originals, copies)
841+
case _ =>
840842
}
841843

842844
copies.foreach(_.ensureCompleted()) // avoid memory leak

tests/pos/i10542.scala

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package test_10542:
2+
3+
trait Foo {
4+
inline def foo[A](t: => A): Unit = ()
5+
}
6+
7+
object Bar extends Foo
8+
9+
object Test {
10+
Bar.foo {
11+
sealed trait T1
12+
case object S1 extends T1
13+
}
14+
}
15+
16+
package test_10540:
17+
18+
trait Foo {
19+
inline def foo[A](t: => A): Unit = ()
20+
}
21+
22+
object Bar extends Foo
23+
24+
object Test {
25+
Bar.foo {
26+
trait T1
27+
val array = Array(new T1 {})
28+
}
29+
}
30+
31+
package test_9655:
32+
33+
inline def foo[T](inline body: T): T = body
34+
35+
def test = foo {
36+
sealed trait Status
37+
object Active extends Status
38+
}

0 commit comments

Comments
 (0)