Skip to content

Commit 52ee0c3

Browse files
som-snytttgodzik
authored andcommitted
Unused check of secondary constructor param
[Cherry-picked aef0a25]
1 parent 363654c commit 52ee0c3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

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

607607
// does the param have an alias in a default arg method that is used?
608608
def usedByDefaultGetter(param: Symbol, meth: Symbol): Boolean =
609-
val cls = if meth.isPrimaryConstructor then meth.enclosingClass.companionModule else meth.enclosingClass
609+
val cls = if meth.isConstructor then meth.enclosingClass.companionModule else meth.enclosingClass
610610
val MethName = meth.name
611611
cls.info.decls.exists: d =>
612612
d.name match

tests/warn/i23349.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ class K(k: Int)(s: String = "*"*k):
2424

2525
class KU(using k: Int)(s: String = "*"*k):
2626
override val toString = s
27+
28+
class KK(s: String):
29+
def this(k: Int)(s: String = "*"*k) = this(s)
30+
override val toString = s

0 commit comments

Comments
 (0)