summaryrefslogtreecommitdiff
path: root/sources/scalac/typechecker
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-09-23 10:44:18 +0000
committerMartin Odersky <odersky@gmail.com>2003-09-23 10:44:18 +0000
commitec5d770a7ce7dc76fb7a0639777f4eeacb74e613 (patch)
tree5398d779c5017bbe616791f4514917c885790621 /sources/scalac/typechecker
parent409a65421cc625693a1c60af63dbf27c7efd63fb (diff)
downloadscala-ec5d770a7ce7dc76fb7a0639777f4eeacb74e613.tar.gz
scala-ec5d770a7ce7dc76fb7a0639777f4eeacb74e613.tar.bz2
scala-ec5d770a7ce7dc76fb7a0639777f4eeacb74e613.zip
*** empty log message ***
Diffstat (limited to 'sources/scalac/typechecker')
-rw-r--r--sources/scalac/typechecker/Analyzer.java23
-rw-r--r--sources/scalac/typechecker/Context.java4
2 files changed, 17 insertions, 10 deletions
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index c456a33f7a..f840da0c30 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -1834,10 +1834,14 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Tree tpe1 = (tpe == Tree.Empty)
? gen.mkType(tree.pos, sym.type().resultType())
: transform(tpe, TYPEmode);
- Tree rhs1 = transform(
- rhs,
- (name == Names.CONSTRUCTOR) ? CONSTRmode : EXPRmode,
- tpe1.type);
+ Tree rhs1 = rhs;
+ if (rhs1 != Tree.Empty) {
+ rhs1 = transform(
+ rhs,
+ (name == Names.CONSTRUCTOR) ? CONSTRmode : EXPRmode,
+ tpe1.type);
+ }
+ popContext();
context.enclClass.owner.flags &= ~INCONSTRUCTOR;
sym.flags |= LOCKED;
checkNonCyclic(tree.pos, tpe1.type);
@@ -1889,8 +1893,10 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Tree[] stats1 = desugarize.Statements(stats, true);
enterSyms(stats1);
context.imports = context.outer.imports;
- if (mode == CONSTRmode) {
- stats1[0] = transform(stats1[0], mode, pt);
+ Type owntype;
+ int curmode = mode;
+ if ((curmode & CONSTRmode) != 0) {
+ stats1[0] = transform(stats1[0], curmode, pt);
context.enclClass.owner.flags &= ~INCONSTRUCTOR;
for (int i = 1; i < stats1.length; i++)
stats1[i] = transform(stats1[i], EXPRmode);
@@ -1898,10 +1904,9 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
} else {
for (int i = 0; i < stats1.length - 1; i++)
stats1[i] = transform(stats1[i], EXPRmode);
- Type owntype;
- if (stats1.length > start) {
+ if (stats1.length > 0) {
stats1[stats1.length - 1] =
- transform(stats1[stats1.length - 1], EXPRmode, pt);
+ transform(stats1[stats1.length - 1], curmode & ~FUNmode, pt);
owntype = checkNoEscape(tree.pos, stats1[stats1.length - 1].type);
} else {
owntype = definitions.UNIT_TYPE;
diff --git a/sources/scalac/typechecker/Context.java b/sources/scalac/typechecker/Context.java
index 4c5f761c1f..61bf0a8299 100644
--- a/sources/scalac/typechecker/Context.java
+++ b/sources/scalac/typechecker/Context.java
@@ -20,6 +20,7 @@ public class Context {
Context enclClass = this; // The next outer context whose tree
// is a class template
int variance; // Variance relative to enclosing class.
+ Symbol constructorClass; // Class for auxiliary constructor
public Context() {}
@@ -29,13 +30,14 @@ public class Context {
public Context(Tree tree, Symbol owner, Scope scope, Context outer) {
this.tree = tree;
-Pa this.owner = owner;
+ this.owner = owner;
this.scope = scope;
this.imports = outer.imports;
if (tree instanceof Tree.Template ||
tree instanceof Tree.CompoundType) this.enclClass = this;
else this.enclClass = outer.enclClass;
this.variance = outer.variance;
+ this.constructorClass = outer.constructorClass;
this.outer = outer;
}