File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
compiler/src/dotty/tools/dotc/typer
tests/neg-custom-args/fatal-warnings Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -771,13 +771,17 @@ class Typer extends Namer
771771 def typedTpt = checkSimpleKinded(typedType(tree.tpt))
772772 def handlePattern : Tree = {
773773 val tpt1 = typedTpt
774- if (! ctx.isAfterTyper && pt != defn.ImplicitScrutineeTypeRef )
775- checkMatchable(pt, tree.srcPos, pattern = true )
774+ if ! ctx.isAfterTyper && pt != defn.ImplicitScrutineeTypeRef then
776775 withMode(Mode .GadtConstraintInference ) {
777776 TypeComparer .constrainPatternType(tpt1.tpe, pt)
778777 }
778+ val matched = ascription(tpt1, isWildcard = true )
779779 // special case for an abstract type that comes with a class tag
780- tryWithTypeTest(ascription(tpt1, isWildcard = true ), pt)
780+ val result = tryWithTypeTest(ascribed, pt)
781+ if (result eq matched) && pt != defn.ImplicitScrutineeTypeRef then
782+ // no check for matchability if TestTest was applied
783+ checkMatchable(pt, tree.srcPos, pattern = true )
784+ result
781785 }
782786 cases(
783787 ifPat = handlePattern,
Original file line number Diff line number Diff line change 1+ import scala .language .`3.1-migration`
2+ import scala .reflect .TypeTest
3+
4+ trait Foo :
5+ type X
6+ type Y <: X
7+ def x : X
8+ given TypeTest [X , Y ] = ???
9+
10+ object Test :
11+ def test (foo : Foo ): Unit =
12+ foo.x match
13+ case x : foo.Y =>
You can’t perform that action at this time.
0 commit comments