Skip to content

Commit 7ed0041

Browse files
committed
Avoid redundant type test for irrefutable @unchecked patterns
Fixes #14896
1 parent d673b97 commit 7ed0041

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-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
@@ -1378,7 +1378,7 @@ trait Applications extends Compatibility {
13781378
val unapplyPatterns = bunchedArgs.lazyZip(argTypes) map (typed(_, _))
13791379
val result = assignType(cpy.UnApply(tree)(unapplyFn, unapplyImplicits(unapplyApp), unapplyPatterns), ownType)
13801380
unapp.println(s"unapply patterns = $unapplyPatterns")
1381-
if ((ownType eq selType) || ownType.isError) result
1381+
if (ownType.stripped eq selType.stripped) || ownType.isError then result
13821382
else tryWithTypeTest(Typed(result, TypeTree(ownType)), selType)
13831383
case tp =>
13841384
val unapplyErr = if (tp.isError) unapplyFn else notAnExtractor(unapplyFn)

tests/pos/i14896.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
object Ex { def unapply(p: Any): Option[_ <: Int] = null }
2+
object Foo { val Ex(_) = null: @unchecked }

0 commit comments

Comments
 (0)