@@ -33,7 +33,7 @@ import NameOps._
33
33
import SymDenotations .{NoCompleter , NoDenotation }
34
34
import Applications .unapplyArgs
35
35
import Inferencing .isFullyDefined
36
- import transform .patmat .SpaceEngine .{isIrrefutable , isIrrefutableQuotedPattern }
36
+ import transform .patmat .SpaceEngine .{isIrrefutable , isIrrefutableQuotePattern }
37
37
import config .Feature
38
38
import config .Feature .sourceVersion
39
39
import config .SourceVersion ._
@@ -846,19 +846,15 @@ trait Checking {
846
846
val problem = if pat.tpe <:< reportedPt then " is more specialized than" else " does not match"
847
847
em " pattern's type ${pat.tpe} $problem the right hand side expression's type $reportedPt"
848
848
case RefutableExtractor =>
849
- val extractor =
850
- val UnApply (fn, _, _) = pat : @ unchecked
851
- tpd.funPart(fn) match
852
- case Select (id, _) => id
853
- case _ => EmptyTree
854
- if extractor.isEmpty then
855
- em " pattern binding uses refutable extractor "
856
- else if extractor.symbol eq defn.QuoteMatching_ExprMatch then
857
- em " pattern binding uses refutable extractor `'{...}` "
858
- else if extractor.symbol eq defn.QuoteMatching_TypeMatch then
859
- em " pattern binding uses refutable extractor `'[...]` "
860
- else
861
- em " pattern binding uses refutable extractor ` $extractor` "
849
+ val extractor = pat match
850
+ case UnApply (fn, _, _) =>
851
+ tpd.funPart(fn) match
852
+ case Select (id, _) if ! id.isEmpty => id.show
853
+ case _ => " "
854
+ case QuotePattern (_, body, _) =>
855
+ if body.isTerm then " '{...}" else " '[...]"
856
+ if extractor.isEmpty then em " pattern binding uses refutable extractor "
857
+ else em " pattern binding uses refutable extractor ` $extractor` "
862
858
863
859
val fix =
864
860
if isPatDef then " adding `: @unchecked` after the expression"
@@ -897,7 +893,7 @@ trait Checking {
897
893
recur(pat1, pt)
898
894
case UnApply (fn, implicits, pats) =>
899
895
check(pat, pt) &&
900
- (isIrrefutable(fn, pats.length) || isIrrefutableQuotedPattern(fn, implicits, pt) || fail(pat, pt, Reason .RefutableExtractor )) && {
896
+ (isIrrefutable(fn, pats.length) || fail(pat, pt, Reason .RefutableExtractor )) && {
901
897
val argPts = unapplyArgs(fn.tpe.widen.finalResultType, fn, pats, pat.srcPos)
902
898
pats.corresponds(argPts)(recur)
903
899
}
@@ -907,6 +903,8 @@ trait Checking {
907
903
check(pat, pt) && recur(arg, pt)
908
904
case Ident (nme.WILDCARD ) =>
909
905
true
906
+ case pat : QuotePattern =>
907
+ isIrrefutableQuotePattern(pat, pt) || fail(pat, pt, Reason .RefutableExtractor )
910
908
case _ =>
911
909
check(pat, pt)
912
910
}
0 commit comments