Skip to content

Commit

Permalink
allow literal true instead of Boolean as extractor type
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnhoekstra committed Dec 1, 2020
1 parent ad7deb6 commit 2cfdb05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -127,7 +127,7 @@ trait PatternExpansion {
// rest is private
private val isUnapply = fun.symbol.name == nme.unapply
private val isUnapplySeq = fun.symbol.name == nme.unapplySeq
private def isBooleanUnapply = isUnapply && unapplyResultType() =:= BooleanTpe
private def isBooleanUnapply = isUnapply && unapplyResultType() <:< BooleanTpe
private def isRepeatedCaseClass = caseCtorParamTypes.exists(tpes => tpes.nonEmpty && isScalaRepeatedParamType(tpes.last))

private def caseCtorParamTypes: Option[List[Type]] =
Expand Down
12 changes: 12 additions & 0 deletions test/files/pos/t12232_.scala
@@ -0,0 +1,12 @@
object Test {
sealed trait Foo
final class Bar extends Foo

object Bar {
def unapply(o: Bar): true = true
}

def f(foo: Foo) = foo match {
case Bar() => println("Bar")
}
}

0 comments on commit 2cfdb05

Please sign in to comment.