aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorOndrej Lhotak <olhotak@uwaterloo.ca>2014-10-30 17:08:22 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-11-22 20:10:22 +0100
commitf1602ab22bf0b26d2e68bf564e6f53271a5707d2 (patch)
tree35444ea6482e855aafa5add1c43d310ad30416ca /src/dotty/tools/dotc/typer/Namer.scala
parent44ae00661116be3158f0c3dec94fb9a1951f7895 (diff)
downloaddotty-f1602ab22bf0b26d2e68bf564e6f53271a5707d2.tar.gz
dotty-f1602ab22bf0b26d2e68bf564e6f53271a5707d2.tar.bz2
dotty-f1602ab22bf0b26d2e68bf564e6f53271a5707d2.zip
For Java constructors, do not move out to ctx.outer
A Java constructor needs to see the import of the companion object of the class. It is not necessary to move to an outer context because a Java constructor does not have an implementation. scalac also does it this way: see Namers.Namer.createNamer.isConstrParam.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 0ca681d32..bc64e10fc 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -243,7 +243,10 @@ class Namer { typer: Typer =>
// different: The former must have the class as owner (because the
// constructor is owned by the class), the latter must not (because
// constructor parameters are interpreted as if they are outside the class).
- val cctx = if (tree.name == nme.CONSTRUCTOR) ctx.outer else ctx
+ // Don't do this for Java constructors because they need to see the import
+ // of the companion object, and it is not necessary for them because they
+ // have no implementation.
+ val cctx = if (tree.name == nme.CONSTRUCTOR && !(tree.mods is JavaDefined)) ctx.outer else ctx
record(ctx.newSymbol(
ctx.owner, name, tree.mods.flags | deferred | method | higherKinded | inSuperCall1,