Skip to content

Commit

Permalink
add test cases to caseclass_private_constructor.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper-M committed Sep 9, 2019
1 parent 7bf8736 commit 491a536
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/files/neg/caseclass_private_constructor.check
Expand Up @@ -42,4 +42,12 @@ caseclass_private_constructor.scala:41: error: method copy in class F cannot be
class F in object qualified_protected where target is defined
def f2: F = f2.copy(2) // error: copy is protected
^
10 errors found
caseclass_private_constructor.scala:55: error: method copy in class OverrideApply cannot be accessed in OverrideApply
def oa = OverrideApply(42).copy(24) // error: copy is still private
^
caseclass_private_constructor.scala:56: error: method apply in object OverrideCopy cannot be accessed in object OverrideCopy
error after rewriting to OverrideCopy.<apply: error>
possible cause: maybe a wrong Dynamic method signature?
def oc = OverrideCopy(42) // error: apply is still private
^
12 errors found
15 changes: 15 additions & 0 deletions test/files/neg/caseclass_private_constructor.scala
Expand Up @@ -40,3 +40,18 @@ object QProtTest {
def f1: F = F(1)
def f2: F = f2.copy(2) // error: copy is protected
}


case class OverrideApply private (i: Int)
object OverrideApply {
def apply(i: Int): OverrideApply = new OverrideApply(i)
}

case class OverrideCopy private (i: Int) {
def copy(i: Int = i): OverrideCopy = OverrideCopy(i)
}

object OverrideTest {
def oa = OverrideApply(42).copy(24) // error: copy is still private
def oc = OverrideCopy(42) // error: apply is still private
}
15 changes: 15 additions & 0 deletions test/files/pos/caseclass_private_constructor.scala
Expand Up @@ -45,3 +45,18 @@ object qualified_protected {
object CQualifiedTest {
def c = qualified_protected.C(1) // apply is public
}


case class OverrideApply private (i: Int)
object OverrideApply {
def apply(i: Int): OverrideApply = new OverrideApply(i)
}

case class OverrideCopy private (i: Int) {
def copy(i: Int = i): OverrideCopy = OverrideCopy(i)
}

object OverrideTest {
def oa = OverrideApply(42) // overridden apply is public
def oc(o: OverrideCopy) = o.copy(42) // overridden copy is public
}

0 comments on commit 491a536

Please sign in to comment.