Skip to content

Commit 03efed4

Browse files
committed
Fix #3050
1 parent a84bcf5 commit 03efed4

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

compiler/src/dotty/tools/dotc/typer/ReTyper.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class ReTyper extends Typer {
5858
}
5959

6060
override def typedUnApply(tree: untpd.UnApply, selType: Type)(implicit ctx: Context): UnApply = {
61-
val fun1 = typedExpr(tree.fun, AnyFunctionProto)
61+
val funProto = new UnapplyFunProto(WildcardType, this)
62+
63+
val fun1 = typedExpr(tree.fun, funProto)
6264
val implicits1 = tree.implicits.map(typedExpr(_))
6365
val patterns1 = tree.patterns.mapconserve(pat => typed(pat, pat.tpe))
6466
untpd.cpy.UnApply(tree)(fun1, implicits1, patterns1).withType(tree.tpe)

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2125,7 +2125,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
21252125
tree match {
21262126
case _: RefTree | _: Literal
21272127
if !isVarPattern(tree) &&
2128-
!(tree.tpe <:< pt)(ctx.addMode(Mode.GADTflexible)) =>
2128+
!(tree.tpe <:< pt)(ctx.addMode(Mode.GADTflexible)) &&
2129+
!this.isInstanceOf[ReTyper] =>
21292130
val cmp =
21302131
untpd.Apply(
21312132
untpd.Select(untpd.TypedSplice(tree), nme.EQ),

tests/pos/i3050.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test {
2+
inline def openImpl(): Int =
3+
Some(42) match { case Some(i) => i }
4+
5+
def open(): Int = openImpl()
6+
7+
inline def openImpl2(): Int =
8+
Some(42) match { case None => 42 }
9+
10+
def open2(): Int = openImpl2()
11+
}

0 commit comments

Comments
 (0)