Skip to content

Commit ddea9bb

Browse files
som-snytttgodzik
authored andcommitted
Nowarn non-private implicit val class params
Dowarn protected param accessor of given, which was probably widened. [Cherry-picked 2cb2c92]
1 parent ba16067 commit ddea9bb

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/warn/i15503f.scala

+32
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,35 @@ object Unmatched:
4343
case Ident(name) =>
4444
case _ =>
4545
e
46+
47+
trait Ctx
48+
case class K(i: Int)(using val ctx: Ctx) // nowarn
49+
class L(val i: Int)(using val ctx: Ctx) // nowarn
50+
class M(val i: Int)(using ctx: Ctx) // warn
51+
52+
package givens:
53+
54+
trait X:
55+
def doX: Int
56+
57+
trait Y:
58+
def doY: String
59+
60+
given X:
61+
def doX = 7
62+
63+
given X => Y: // warn protected param to given class
64+
def doY = "7"
65+
/* desugared. It is protected so that its type can be used in member defs without leaking.
66+
* possibly it should be protected only for named parameters.
67+
given class given_Y(using x$1: givens.X) extends Object(), givens.Y {
68+
protected given val x$1: givens.X
69+
def doY: String = "7"
70+
}
71+
final given def given_Y(using x$1: givens.X): givens.given_Y =
72+
new givens.given_Y(using x$1)()
73+
*/
74+
75+
given namely: (x: X) => Y: // warn protected param to given class
76+
def doY = "8"
77+
end givens

0 commit comments

Comments
 (0)