Skip to content

Commit d45f06e

Browse files
committed
Unused check of secondary constructor param
1 parent 3ade37d commit d45f06e

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
@@ -572,7 +572,7 @@ object CheckUnused:
572572

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