Skip to content
Closed
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
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ object Flags {
* an existentially bound symbol (Scala 2.x only) */
val (Scala2SpecialFlags @ _, Scala2SuperAccessor @ _, Scala2Existential @ _) = newFlags(55, "<existential>")

/** Children were queried on this class */
val (_, _, ChildrenQueried @ _) = newFlags(56, "<children-queried>")
/** A class parameter that is not a `val` / Children were queried on this class */
val (_, NotAField @ _, ChildrenQueried @ _) = newFlags(56, "<not-a-field>", "<children-queried>")

/** A module variable (Scala 2.x only) / a capture-checked class
* (Scala2ModuleVar is re-used as a flag for private parameter accessors in Recheck)
Expand Down Expand Up @@ -475,7 +475,7 @@ object Flags {
Scala2SpecialFlags, MutableOrOpen, Opaque, Touched, JavaStatic,
OuterOrCovariant, LabelOrContravariant, CaseAccessor, Tracked,
Extension, NonMember, Implicit, Given, Permanent, Synthetic, Exported,
SuperParamAliasOrScala2x, Inline, Macro, PhantomSymbol, Invisible)
SuperParamAliasOrScala2x, Inline, Macro, PhantomSymbol, Invisible, NotAField)

/** Flags that are not (re)set when completing the denotation, or, if symbol is
* a top-level class or object, when completing the denotation once the class
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,7 @@ object SymDenotations {
* determined by whether they have a `val` or `var` or not.
*/
def canBeLocal(name: Name, flags: FlagSet)(using Context) =
!name.isConstructorName && !flags.is(Param) && !flags.is(ParamAccessor)
!name.isConstructorName && !flags.is(NotAField)

/** Factory method for SymDenotion creation. All creations
* should be done via this method.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3679,7 +3679,7 @@ object Parsers {
if (!(mods.flags &~ (ParamAccessor | Inline | Erased | impliedMods.flags)).isEmpty)
syntaxError(em"`val` or `var` expected")
if firstClause && paramOwner == ParamOwner.CaseClass then mods
else mods | PrivateLocal
else mods | PrivateLocal | NotAField
else {
if (isIdent(nme.inline) && in.isSoftModifierInParamModifierPosition)
mods = addModifier(mods)
Expand Down
4 changes: 0 additions & 4 deletions tests/neg/i22620.scala

This file was deleted.

3 changes: 3 additions & 0 deletions tests/pos/i22620.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import scala.collection.mutable.ArrayBuffer

class PrivateTest[-M](private val v: ArrayBuffer[M])
7 changes: 7 additions & 0 deletions tests/pos/i22620b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sealed abstract class Tree[+A](
final val key: A
)
final class RedTree[+A](key: A) extends Tree[A](key)
object RedTree {
def unapply[A](t: RedTree[A]) = Some((t.key))
}
4 changes: 2 additions & 2 deletions tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ classes/C6#`<init>`().(x) => param x: Int
classes/C6#copy$default$1(). => method copy$default$1 => Int @uncheckedVariance
classes/C6#copy(). => method copy (param x: Int): C6
classes/C6#copy().(x) => param x: Int
classes/C6#x. => private val method x Int
classes/C6#x. => private[this] val method x Int
classes/C6. => final object C6 extends Object { self: C6.type => +4 decls }
classes/C6.apply(). => method apply (param x: Int): C6
classes/C6.apply().(x) => param x: Int
Expand Down Expand Up @@ -1957,7 +1957,7 @@ example/ImplicitConversion.newAny2stringadd#`+`(). => method + (param other: Str
example/ImplicitConversion.newAny2stringadd#`+`().(other) => param other: String
example/ImplicitConversion.newAny2stringadd#`<init>`(). => primary ctor <init> [typeparam A ](param self: A): newAny2stringadd[A]
example/ImplicitConversion.newAny2stringadd#`<init>`().(self) => param self: A
example/ImplicitConversion.newAny2stringadd#self. => private val method self A
example/ImplicitConversion.newAny2stringadd#self. => private[this] val method self A
example/ImplicitConversion.newAny2stringadd(). => final implicit method newAny2stringadd [typeparam A ](param self: A): newAny2stringadd[A]
example/ImplicitConversion.newAny2stringadd().(self) => param self: A
example/ImplicitConversion.newAny2stringadd().[A] => typeparam A
Expand Down
2 changes: 1 addition & 1 deletion tests/warn/i15503c.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package foo.test.constructors:
case class A private (x: Int) // OK
class B private (val x: Int) // OK
object B { def default = B(42) }
class C private (private val xy: Int) // warn
class C private (private val xy: Int)
object C { def default = C(42) }
class D private (private val x: Int): // OK
def y = x
Expand Down
Loading