Skip to content

Commit 0433cbc

Browse files
liufengyunOlivierBlanvillain
authored andcommitted
Fix #5638: disallow get of named match to be PolyType
1 parent 7fd5d68 commit 0433cbc

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object Applications {
4040
import tpd._
4141

4242
def extractorMember(tp: Type, name: Name)(implicit ctx: Context): SingleDenotation =
43-
tp.member(name).suchThat(_.info.isParameterless)
43+
tp.member(name).suchThat(sym => sym.info.isParameterless && sym.info.widenExpr.isValueType)
4444

4545
def extractorMemberType(tp: Type, name: Name, errorPos: SourcePosition)(implicit ctx: Context): Type = {
4646
val ref = extractorMember(tp, name)

tests/neg/i5638.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Opt{
2+
def isEmpty: Boolean = false
3+
def get[T]: Int = 1
4+
}
5+
object Extract{
6+
def unapply(x: Int): Opt = new Opt
7+
}
8+
object O {
9+
def m(x: Int) = x match {
10+
case Extract(r) => // error
11+
r // error
12+
}
13+
}

0 commit comments

Comments
 (0)