Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b275b38

Browse files
committed
un-deprecate package object inheritance
1 parent 2c235fc commit b275b38

8 files changed

Lines changed: 5 additions & 56 deletions

File tree

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3369,11 +3369,6 @@ self =>
33693369
val templateOffset = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart
33703370
val templatePos = o2p(templateOffset)
33713371

3372-
// warn now if user wrote parents for package object; `gen.mkParents` adds AnyRef to parents
3373-
if (currentRun.isScala3 && name == nme.PACKAGEkw && !parents.isEmpty)
3374-
migrationWarning(tstart, sm"""|package object inheritance is deprecated (https://github.com/scala/scala-dev/issues/441);
3375-
|drop the `extends` clause or use a regular object instead""", "3.0.0")
3376-
33773372
atPos(templateOffset) {
33783373
// Exclude only the 9 primitives plus AnyVal.
33793374
if (inScalaRootPackage && ScalaValueClassNames.contains(name))

test/files/neg/deprecate_package_object_extends.check

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/files/neg/deprecate_package_object_extends.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/files/neg/t11921b.check

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
t11921b.scala:135: error: could not find implicit value for parameter i: Int
22
def u = t // doesn't compile in Scala 2 (maybe there's a ticket for that)
33
^
4-
t11921b.scala:151: error: package object inheritance is deprecated (https://github.com/scala/scala-dev/issues/441);
5-
drop the `extends` clause or use a regular object instead
6-
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
7-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
8-
package object pt12850 extends t12850 {
9-
^
104
t11921b.scala:11: error: reference to x is ambiguous;
115
it is both defined in the enclosing object Test and inherited in the enclosing class D as value x (defined in class C)
126
In Scala 2, symbols inherited from a superclass shadow symbols defined in an outer scope.
@@ -79,4 +73,4 @@ Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to
7973
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=test10.C.v
8074
def v = t(lo) // error
8175
^
82-
10 errors
76+
9 errors

test/files/neg/t12798-migration.check

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ To express the assignment expression, wrap it in brackets, e.g., `{ z = ... }`.
66
t12798-migration.scala:25: warning: unary prefix operator definition with empty parameter list is unsupported: instead, remove () to declare as `def unary_- = -42` [quickfixable]
77
def unary_-() = -42
88
^
9-
t12798-migration.scala:28: warning: package object inheritance is deprecated (https://github.com/scala/scala-dev/issues/441);
10-
drop the `extends` clause or use a regular object instead
11-
package object tester extends Runnable {
12-
^
139
t12798-migration.scala:33: warning: procedure syntax is deprecated for constructors: add `=`, as in method definition [quickfixable]
1410
def this(s: String) { this() }
1511
^
@@ -50,5 +46,5 @@ case class `case mods propagate` private (s: String)
5046
t12798-migration.scala:52: warning: access modifiers for `apply` method are copied from the case class constructor
5147
case class `copyless case mods propagate` private (s: String) {
5248
^
53-
15 warnings
49+
14 warnings
5450
1 error

test/files/neg/t12798.check

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to
88
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
99
def unary_-() = -42
1010
^
11-
t12798.scala:28: error: package object inheritance is deprecated (https://github.com/scala/scala-dev/issues/441);
12-
drop the `extends` clause or use a regular object instead
13-
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
14-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
15-
package object tester extends Runnable {
16-
^
1711
t12798.scala:33: error: procedure syntax is deprecated for constructors: add `=`, as in method definition [quickfixable]
1812
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
1913
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
@@ -75,4 +69,4 @@ Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to
7569
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=copyless case mods propagate.apply
7670
case class `copyless case mods propagate` private (s: String) {
7771
^
78-
15 errors
72+
14 errors

test/files/neg/t12816.check

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
t12816.scala:8: error: package object inheritance is deprecated (https://github.com/scala/scala-dev/issues/441);
2-
drop the `extends` clause or use a regular object instead
3-
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
4-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
5-
package object p extends U {
6-
^
71
t12816.scala:29: error: reference to c is ambiguous;
82
it is both defined in the enclosing package p and inherited in the enclosing trait RR as method c (defined in trait T)
93
In Scala 2, symbols inherited from a superclass shadow symbols defined in an outer scope.
@@ -22,4 +16,4 @@ Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to
2216
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=p.RR.n3
2317
def n3: Z // warn
2418
^
25-
3 errors
19+
2 errors

test/files/neg/t12816b.check

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
A.scala:5: error: package object inheritance is deprecated (https://github.com/scala/scala-dev/issues/441);
2-
drop the `extends` clause or use a regular object instead
3-
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
4-
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
5-
package object p extends U {
6-
^
71
B.scala:19: error: reference to c is ambiguous;
82
it is both defined in the enclosing package p and inherited in the enclosing trait RR as method c (defined in trait T)
93
In Scala 2, symbols inherited from a superclass shadow symbols defined in an outer scope.
@@ -22,4 +16,4 @@ Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to
2216
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=p.RR.n3
2317
def n3: Z // warn
2418
^
25-
3 errors
19+
2 errors

0 commit comments

Comments
 (0)