Skip to content

Commit 1fc2a3f

Browse files
committed
Allow implicit parameters in extractors
1 parent 01447df commit 1fc2a3f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-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
@@ -1581,7 +1581,7 @@ trait Applications extends Compatibility {
15811581
val newAcc =
15821582
params match
15831583
case param :: _ if param.isType => true
1584-
case param :: _ if param.isTerm && !param.isOneOf(GivenOrImplicit) => false
1584+
case param :: _ if param.isTerm && !param.is(Given) => false
15851585
case _ => acc
15861586
hasTrailingTypeParams(paramss.tail, newAcc)
15871587

tests/pos/i23499.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def summonsTest =
2+
given Type[String] = ???
3+
val opt1: Option[Wrapper[String]] = Wrapper.unapply[String] // ok
4+
val opt2 = Wrapper.unapply[String]
5+
opt2.map(_.getValue)
6+
7+
def patternMatchTest =
8+
Type[String] match
9+
case Wrapper(v) => v.getValue // was an error
10+
11+
type Type[A] = Class[A] // any rhs would work here
12+
object Type:
13+
def apply[A]: Type[A] = ???
14+
15+
trait Wrapper[T]:
16+
def getValue: T = ???
17+
object Wrapper:
18+
def unapply[T](implicit ev: Type[T]): Option[Wrapper[T]] = None

0 commit comments

Comments
 (0)