Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/_docs/reference/dropped-features/this-qualifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ This can cause problems if a program tries to access the missing private field v
// [C] needed if `field` is to be accessed through reflection
val retained = field * field
```

Class parameters are normally inferred object-private,
so that members introduced by explicitly declaring them `val` or `var` are exempt from the rule described here.

In particular, the following field is not excluded from variance checking:
```scala
class C[-T](private val t: T) // error
```
And in contrast to the private field shown above, this field is not eliminated:
```scala
class C(private val c: Int)
```
4 changes: 4 additions & 0 deletions tests/neg/i22620.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

import scala.collection.mutable.ArrayBuffer

class PrivateTest[-M](private val v: ArrayBuffer[M]) // error
Loading