Skip to content

Commit 280744e

Browse files
committed
Update docs
and fix test comment
1 parent f9aff3e commit 280744e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

docs/docs/reference/dropped-features/package-objects.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Package objects are no longer needed since all kinds of definitions can now be w
2525
def (x: C) pair (y: C) = (x, y)
2626
}
2727
```
28-
There may be several source files in a package containing such toplevel definitions, and source files can freely mix toplevel value, method, and tyoe definitions with classes and objects.
28+
There may be several source files in a package containing such toplevel definitions, and source files can freely mix toplevel value, method, and type definitions with classes and objects.
2929

30-
The compiler generates synthetic objects that wrap toplevel statements that are not imports, or class or object definitions. If a source file `src.scala` contains such toplevel statements, they will be put in a synthetic object named `src$package`. The wrapping is transparent, however. The definitions in `f` can still be accessed as members of the enclosing package.
30+
The compiler generates synthetic objects that wrap toplevel definitions falling into one of the following categories:
31+
32+
- all pattern, value, method, and type definitions,
33+
- implicit classes and objects,
34+
- companion objects of opaque types.
35+
36+
If a source file `src.scala` contains such toplevel definitions, they will be put in a synthetic object named `src$package`. The wrapping is transparent, however. The definitions in `src` can still be accessed as members of the enclosing package.

tests/pos/toplevel-opaque/Test.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object Test {
2-
val x: T[Int] = ??? //2 // error
3-
val y: Int = 1 // x // error
4-
val a: Int = T.f(x) // ok
5-
val b: T[Int] = T.g(y) // ok
2+
val x: T[Int] = ???
3+
val y: Int = 1
4+
val a: Int = T.f(x)
5+
val b: T[Int] = T.g(y)
66
}

0 commit comments

Comments
 (0)