summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-08-15 10:25:51 +0000
committerMartin Odersky <odersky@gmail.com>2003-08-15 10:25:51 +0000
commit260757086149e48d2dbe955335ba959e874a6452 (patch)
tree57c5c0e150aabf04e57dff04a83170e22c7be9f2 /sources
parent396a60a22c2724676071449d55aa9b29cd8c4322 (diff)
downloadscala-260757086149e48d2dbe955335ba959e874a6452.tar.gz
scala-260757086149e48d2dbe955335ba959e874a6452.tar.bz2
scala-260757086149e48d2dbe955335ba959e874a6452.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r--sources/meta/scalac/ast/Tree.java2
-rw-r--r--sources/scalac/typechecker/Analyzer.java44
-rw-r--r--sources/scalac/typechecker/Infer.java53
3 files changed, 67 insertions, 32 deletions
diff --git a/sources/meta/scalac/ast/Tree.java b/sources/meta/scalac/ast/Tree.java
index 44fe88f9d2..39f15f0bfc 100644
--- a/sources/meta/scalac/ast/Tree.java
+++ b/sources/meta/scalac/ast/Tree.java
@@ -327,7 +327,7 @@ public class Tree {
setDescription("Type selection").
setRange(Phase.PARSER, Phase.REFCHECK).
addField(t_TypeTree, "qualifier").
- addField(t_TypeName, "selector", SymName);
+ addField(t_TestName, "selector", SymName);
n_FunType.
setDescription("Function type").
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index 86a9461f27..fa1d391f1c 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -2127,7 +2127,12 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
if (c.kind == CLASS) {
c.initialize();
Tree fn0 = fn1;
- fn1 = gen.mkRef(tree.pos, pre, c.allConstructors());
+ Symbol constr = c.allConstructors();
+ fn1 = gen.mkRef(fn1.pos, pre, constr);
+ switch (fn1) {
+ case Select(Tree fn1qual, _):
+ checkAccessible(fn1.pos, constr, fn1qual);
+ }
if (tsym == c) {
switch (fn0) {
case AppliedType(_, Tree[] targs):
@@ -2137,7 +2142,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
// it was an alias type
// todo: handle overloaded constructors
fn1 = gen.TypeApply(
- fn1, gen.mkTypes(tree.pos, argtypes));
+ fn1, gen.mkTypes(fn1.pos, argtypes));
if (tsym.typeParams().length != 0 &&
!(fn0 instanceof AppliedType))
fn1.type = Type.PolyType(
@@ -2350,8 +2355,39 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
.setType(checkObjectType(tree.pos, ref1.type.resultType()));
case SelectFromType(Tree qual, Name name):
- Tree qual1 = transform(qual, TYPEmode);
- return transformSelect(tree, qual1, name);
+ if ((mode & TYPEmode) != 0) {
+ Tree qual1 = transform(qual, TYPEmode);
+ return transformSelect(tree, qual1, name);
+ } else {
+ Symbol clazz = context.enclClass.owner;
+ if (clazz != null) {
+ Type[] parents = clazz.parents();
+ Name qualname = ((Ident) qual).name;
+ for (int i = 1; i < parents.length; i++) {
+ if (parents[i].symbol().name == qualname) {
+ Symbol bsym = parents[i].lookup(name);
+ if (bsym.kind == NONE) {
+ return error(tree.pos,
+ decode(name) + " is not a member of " +
+ parents[i]);
+ } else if ((bsym.flags & PRIVATE) != 0) {
+ return error(tree.pos,
+ decode(name) + " is not accessible in " +
+ parents[i]);
+ }
+ return gen.Select(
+ tree.pos,
+ gen.mkStableId(tree.pos, clazz.thisType()),
+ bsym);
+ }
+ }
+ return error(qual.pos,
+ qual + " does not name a mixin base class");
+ } else {
+ return error(tree.pos, tree +
+ " can be used only in a class, object, or template");
+ }
+ }
case CompoundType(Tree[] parents, Tree[] refinements):
Tree[] parents1 = transform(parents, TYPEmode);
diff --git a/sources/scalac/typechecker/Infer.java b/sources/scalac/typechecker/Infer.java
index 30ed7086a4..c14515f841 100644
--- a/sources/scalac/typechecker/Infer.java
+++ b/sources/scalac/typechecker/Infer.java
@@ -449,39 +449,38 @@ public class Infer implements Modifiers, Kinds {
: !upper;
tvars[i] = Type.NoType;
Type bound = up ? tparams[i].info() : tparams[i].loBound();
- if (up && bound.symbol() != Global.instance.definitions.ANY_CLASS ||
- !up && bound.symbol() != Global.instance.definitions.ALL_CLASS) {
- boolean cyclic = false;
- for (int j = 0; j < tvars.length; j++) {
- if (bound.contains(tparams[j]) ||
- up && tparams[j].loBound().isSameAs(tparams[i].type()) ||
- !up && tparams[j].info().isSameAs(tparams[i].type())) {
- cyclic |= tvars[j] == Type.NoType;
- solve(tparams, upper, variances, tvars, j);
- }
+ boolean cyclic = false;
+ for (int j = 0; j < tvars.length; j++) {
+ if (bound.contains(tparams[j]) ||
+ up && tparams[j].loBound().isSameAs(tparams[i].type()) ||
+ !up && tparams[j].info().isSameAs(tparams[i].type())) {
+ cyclic |= tvars[j] == Type.NoType;
+ solve(tparams, upper, variances, tvars, j);
}
- if (!cyclic) {
- if (up) {
+ }
+ if (!cyclic) {
+ if (up) {
+ if (bound.symbol() != Global.instance.definitions.ANY_CLASS)
constr.hibounds = new Type.List(
bound.subst(tparams, tvars), constr.hibounds);
- for (int j = 0; j < tvars.length; j++) {
- if (tparams[j].loBound().isSameAs(
- tparams[i].type())) {
- constr.hibounds = new Type.List(
- tparams[j].type().subst(tparams, tvars),
- constr.hibounds);
- }
+ for (int j = 0; j < tvars.length; j++) {
+ if (tparams[j].loBound().isSameAs(
+ tparams[i].type())) {
+ constr.hibounds = new Type.List(
+ tparams[j].type().subst(tparams, tvars),
+ constr.hibounds);
}
- } else {
+ }
+ } else {
+ if (bound.symbol() != Global.instance.definitions.ALL_CLASS)
constr.lobounds = new Type.List(
bound.subst(tparams, tvars), constr.lobounds);
- for (int j = 0; j < tvars.length; j++) {
- if (tparams[j].info().isSameAs(
- tparams[i].type())) {
- constr.lobounds = new Type.List(
- tparams[j].type().subst(tparams, tvars),
- constr.lobounds);
- }
+ for (int j = 0; j < tvars.length; j++) {
+ if (tparams[j].info().isSameAs(
+ tparams[i].type())) {
+ constr.lobounds = new Type.List(
+ tparams[j].type().subst(tparams, tvars),
+ constr.lobounds);
}
}
}