Skip to content

Commit 7cbdadf

Browse files
szymon-rdKordyjan
authored andcommitted
Skip extension method params in WUnused
1 parent 24080f1 commit 7cbdadf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ object CheckUnused:
651651

652652
extension (memDef: tpd.MemberDef)
653653
private def isValidMemberDef(using Context): Boolean =
654-
!memDef.symbol.isUnusedAnnot && !memDef.symbol.isAllOf(Flags.AccessorCreationFlags) && !memDef.name.isWildcard
654+
!memDef.symbol.isUnusedAnnot && !memDef.symbol.isAllOf(Flags.AccessorCreationFlags) && !memDef.name.isWildcard && !memDef.symbol.owner.is(Extension)
655655

656656
private def isValidParam(using Context): Boolean =
657657
val sym = memDef.symbol

tests/neg-custom-args/fatal-warnings/i15503g.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ def f7(a: Int)(using Int) = summon[Int] + a // OK
1212

1313
/* --- Trivial method check --- */
1414
def g1(x: Int) = 1 // OK
15-
def g2(x: Int) = ??? // OK
15+
def g2(x: Int) = ??? // OK
16+
17+
package foo.test.i17101:
18+
type Test[A] = A
19+
extension[A] (x: Test[A]) { // OK
20+
def value: A = x
21+
def causesIssue: Unit = println("oh no")
22+
}

0 commit comments

Comments
 (0)