diff --git a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala index 169f68e2cad9..6dac51c427c1 100644 --- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -692,9 +692,10 @@ object PatternMatcher { val scrutinee = plan.scrutinee (plan.test: @unchecked) match { case NonEmptyTest => - scrutinee - .select(nme.isEmpty, _.info.isParameterless) - .select(nme.UNARY_!, _.info.isParameterless) + constToLiteral( + scrutinee + .select(nme.isEmpty, _.info.isParameterless) + .select(nme.UNARY_!, _.info.isParameterless)) case NonNullTest => scrutinee.testNotNull case GuardTest => diff --git a/tests/pos/i11605.scala b/tests/pos/i11605.scala new file mode 100644 index 000000000000..b23bbb19ffd3 --- /dev/null +++ b/tests/pos/i11605.scala @@ -0,0 +1,14 @@ +package example + +class Extractor[A](val get: A) extends AnyVal { + // https://github.com/scala/scala/pull/9343 + def isEmpty: false = false +} + +object Foo { + def unapply(x: String): Extractor[String] = new Extractor(x) +} + +object Main { + val Foo(a) = "a" +} \ No newline at end of file