Skip to content

Commit aef0a25

Browse files
committed
Unused check of secondary constructor param
1 parent c02dea2 commit aef0a25

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
@@ -568,7 +568,7 @@ object CheckUnused:
568568

569569
// does the param have an alias in a default arg method that is used?
570570
def usedByDefaultGetter(param: Symbol, meth: Symbol): Boolean =
571-
val cls = if meth.isPrimaryConstructor then meth.enclosingClass.companionModule else meth.enclosingClass
571+
val cls = if meth.isConstructor then meth.enclosingClass.companionModule else meth.enclosingClass
572572
val MethName = meth.name
573573
cls.info.decls.exists: d =>
574574
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)