aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliu fengyun <liu@fengy.me>2016-12-13 14:05:09 +0100
committerliu fengyun <liu@fengy.me>2016-12-13 16:48:09 +0100
commit31337d5223eb9c1824ca72ca399e22c1f2dfe990 (patch)
tree0cfa09153cec3fa7b639e6cd6d35d53cbad1bdff
parent7775aab98ce98151d198e88bb676158f58f0cf57 (diff)
downloaddotty-31337d5223eb9c1824ca72ca399e22c1f2dfe990.tar.gz
dotty-31337d5223eb9c1824ca72ca399e22c1f2dfe990.tar.bz2
dotty-31337d5223eb9c1824ca72ca399e22c1f2dfe990.zip
Fix #1786: support use package object in fun call
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Checking.scala2
-rw-r--r--tests/neg/i1786.scala17
-rw-r--r--tests/pos/i1786.scala18
3 files changed, 36 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala
index 0c5a8e5db..d80dfe7c0 100644
--- a/compiler/src/dotty/tools/dotc/typer/Checking.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala
@@ -418,7 +418,7 @@ trait Checking {
/** Check that Java statics and packages can only be used in selections.
*/
def checkValue(tree: Tree, proto: Type)(implicit ctx: Context): tree.type = {
- if (!proto.isInstanceOf[SelectionProto]) {
+ if (!proto.isInstanceOf[SelectionProto] && !proto.isInstanceOf[ApplyingProto]) {
val sym = tree.tpe.termSymbol
// The check is avoided inside Java compilation units because it always fails
// on the singleton type Module.type.
diff --git a/tests/neg/i1786.scala b/tests/neg/i1786.scala
new file mode 100644
index 000000000..7bf513ed8
--- /dev/null
+++ b/tests/neg/i1786.scala
@@ -0,0 +1,17 @@
+package scala
+
+package object meta {
+ def apply(x: Int): Int = x * x
+}
+
+class Test {
+ def f(a: Any): Any = f(meta) // error
+ def g(a: Any): Any = f(scala.meta) // error
+
+ meta { 5 + 4 }
+
+ scala.meta { 3 }
+
+ val m1 = meta // error
+ val m2 = scala.meta // error
+}
diff --git a/tests/pos/i1786.scala b/tests/pos/i1786.scala
new file mode 100644
index 000000000..3b1d3af52
--- /dev/null
+++ b/tests/pos/i1786.scala
@@ -0,0 +1,18 @@
+package scala
+
+package object meta {
+ def apply(x: Int): Int = x * x
+}
+
+class Test {
+ meta { 5 + 4 }
+
+ scala.meta { 3 }
+
+ scala.meta.`package` { 3 }
+
+ // val m1 = meta // error
+ // val m2 = scala.meta // error
+ val m3 = scala.meta.`package`
+ val m4 = meta.`package`
+}