Skip to content

Commit ff91037

Browse files
InlineCaseIntrinsics: add .simplified to fix new-unfriendy types
1 parent a386f63 commit ff91037

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/transform/localopt/InlineCaseIntrinsics.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class InlineCaseIntrinsics extends Optimisation {
4747
case _ => fun
4848
}
4949
val constructor = a.symbol.owner.companionClass.primaryConstructor.asTerm
50-
evalreceiver(a, rollInArgs(argss.tail, New(a.tpe.widenDealias, constructor, argss.head)))
50+
evalreceiver(a, rollInArgs(argss.tail, New(a.tpe.widenDealias.simplified, constructor, argss.head)))
5151

5252
// For synthetic dotty unapplies on case classes:
5353
// - CC.unapply(arg): CC → arg
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trait Trait { self =>
2+
private case class CC(name: String)
3+
4+
def m = {
5+
// The type of this Apply after .widenDealias is an AndType:
6+
// TypeRef(AndType(
7+
// TypeRef(ThisType(TypeRef(NoPrefix,<empty>)),Trait),
8+
// ThisType(TypeRef(ThisType(TypeRef(NoPrefix,<empty>)),Trait))
9+
// ), CC)
10+
// Which cannot be used as is in a New....
11+
12+
val a = CC("")
13+
println(a)
14+
()
15+
}
16+
}

0 commit comments

Comments
 (0)