File tree 3 files changed +36
-1
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -418,7 +418,7 @@ trait Checking {
418
418
/** Check that Java statics and packages can only be used in selections.
419
419
*/
420
420
def checkValue (tree : Tree , proto : Type )(implicit ctx : Context ): tree.type = {
421
- if (! proto.isInstanceOf [SelectionProto ]) {
421
+ if (! proto.isInstanceOf [SelectionProto ] && ! proto. isInstanceOf [ ApplyingProto ] ) {
422
422
val sym = tree.tpe.termSymbol
423
423
// The check is avoided inside Java compilation units because it always fails
424
424
// on the singleton type Module.type.
Original file line number Diff line number Diff line change
1
+ package scala
2
+
3
+ package object meta {
4
+ def apply (x : Int ): Int = x * x
5
+ }
6
+
7
+ class Test {
8
+ def f (a : Any ): Any = f(meta) // error
9
+ def g (a : Any ): Any = f(scala.meta) // error
10
+
11
+ meta { 5 + 4 }
12
+
13
+ scala.meta { 3 }
14
+
15
+ val m1 = meta // error
16
+ val m2 = scala.meta // error
17
+ }
Original file line number Diff line number Diff line change
1
+ package scala
2
+
3
+ package object meta {
4
+ def apply (x : Int ): Int = x * x
5
+ }
6
+
7
+ class Test {
8
+ meta { 5 + 4 }
9
+
10
+ scala.meta { 3 }
11
+
12
+ scala.meta.`package` { 3 }
13
+
14
+ // val m1 = meta // error
15
+ // val m2 = scala.meta // error
16
+ val m3 = scala.meta.`package`
17
+ val m4 = meta.`package`
18
+ }
You can’t perform that action at this time.
0 commit comments