Skip to content

Commit 2a02996

Browse files
committed
Skip extension method params in WUnused
1 parent d640193 commit 2a02996

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

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

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

628628
extension (memDef: tpd.MemberDef)
629629
private def isValidMemberDef(using Context): Boolean =
630-
!memDef.symbol.isUnusedAnnot && !memDef.symbol.isAllOf(Flags.AccessorCreationFlags) && !memDef.name.isWildcard
630+
!memDef.symbol.isUnusedAnnot && !memDef.symbol.isAllOf(Flags.AccessorCreationFlags) && !memDef.name.isWildcard && !memDef.symbol.owner.is(Extension)
631631

632632
private def isValidParam(using Context): Boolean =
633633
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)