summaryrefslogtreecommitdiff
path: root/sources/scalac/typechecker
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-11-18 12:04:17 +0000
committerMartin Odersky <odersky@gmail.com>2003-11-18 12:04:17 +0000
commit79dfd483ebf2d901d93e161436b515e075537dc1 (patch)
treecdf702e9ba556623f3595c0ed2d4df6d2158bba5 /sources/scalac/typechecker
parent3ad58546502ae51ae7c7904f242ec568a6b77fb1 (diff)
downloadscala-79dfd483ebf2d901d93e161436b515e075537dc1.tar.gz
scala-79dfd483ebf2d901d93e161436b515e075537dc1.tar.bz2
scala-79dfd483ebf2d901d93e161436b515e075537dc1.zip
*** empty log message ***
Diffstat (limited to 'sources/scalac/typechecker')
-rw-r--r--sources/scalac/typechecker/Analyzer.java12
-rw-r--r--sources/scalac/typechecker/DeSugarize.java24
-rw-r--r--sources/scalac/typechecker/Infer.java16
3 files changed, 31 insertions, 21 deletions
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index eff8af583f..fcb6eaf0d6 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -217,8 +217,11 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Type checkAccessible(int pos, Symbol sym, Type symtype, Tree site) {
if ((sym.owner().flags & INCONSTRUCTOR) != 0 &&
!(sym.kind == TYPE && sym.isParameter())) {
- error(pos, sym + " cannot be accessed from constructor");
- return Type.ErrorType;
+ switch (site) {
+ case This(_):
+ error(pos, sym + " cannot be accessed from constructor");
+ return Type.ErrorType;
+ }
}
switch (symtype) {
case OverloadedType(Symbol[] alts, Type[] alttypes):
@@ -1547,6 +1550,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Symbol sym = qual.type.lookup(name);
if (sym.kind == NONE) {
//System.out.println(qual.type + " has members " + qual.type.members());//DEBUG
+
return error(tree.pos,
decode(name) + " is not a member of " + qual.type.widen());
} else {
@@ -1661,7 +1665,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
c.initialize();//to detect cycles
if (i > 0 && (c.flags & JAVA) == 0 && c.isExternal()) {
// need to load tree for mixins
- new SourceCompleter(global).complete(c);
+ new SourceCompleter(global, true).complete(c);
}
}
}
@@ -2075,7 +2079,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
restype = applyVisitor.type.deconst();
if (definitions.PARTIALFUNCTION_CLASS.isExternal())
// need to load tree for mixins
- new SourceCompleter(global).complete(
+ new SourceCompleter(global, true).complete(
definitions.PARTIALFUNCTION_CLASS);
return gen.mkPartialFunction(
tree.pos, applyVisitor, isDefinedAtVisitor,
diff --git a/sources/scalac/typechecker/DeSugarize.java b/sources/scalac/typechecker/DeSugarize.java
index 9f0a9a98c7..558549c0d9 100644
--- a/sources/scalac/typechecker/DeSugarize.java
+++ b/sources/scalac/typechecker/DeSugarize.java
@@ -50,14 +50,20 @@ public class DeSugarize implements Kinds, Modifiers {
/** the constructor
*/
- public DeSugarize(Analyzer analyzer, Global global) {
+ /** the constructor
+ */
+ public DeSugarize(TreeFactory make, TreeCopier copy, TreeGen gen,
+ Infer infer, Global global) {
this.global = global;
- this.make = analyzer.make;
- this.copy = analyzer.copy;
- this.gen = analyzer.gen;
- this.infer = analyzer.infer;
+ this.make = make;
+ this.copy = copy;
+ this.gen = gen;
+ this.infer = infer;
this.freshNameCreator = global.freshNameCreator;
}
+ public DeSugarize(Analyzer analyzer, Global global) {
+ this(analyzer.make, analyzer.copy, analyzer.gen, analyzer.infer, global);
+ }
// Auxiliary definitions and functions -------------------------------------------
@@ -180,7 +186,7 @@ public class DeSugarize implements Kinds, Modifiers {
vparam.tpe = gen.mkType(vparam.pos, pt);
}
- Tree isDefinedAtVisitor(Tree tree) {
+ public Tree isDefinedAtVisitor(Tree tree) {
switch (tree) {
case Visitor(CaseDef[] cases):
CaseDef lastCase = cases[cases.length - 1];
@@ -220,7 +226,7 @@ public class DeSugarize implements Kinds, Modifiers {
* match[targs] => this.match[targs]
* IMPORTANT: tree is already attributed and attributes need to be preserved.
*/
- Tree postMatch(Tree tree, Symbol currentclazz) {
+ public Tree postMatch(Tree tree, Symbol currentclazz) {
switch (tree) {
case Ident(Name name):
return
@@ -626,7 +632,7 @@ public class DeSugarize implements Kinds, Modifiers {
/** Build value element definition name for case parameter.
*/
- void addCaseElement(TreeList ts, ValDef vparam) {
+ public void addCaseElement(TreeList ts, ValDef vparam) {
//vparam.symbol().initialize();
ts.append(
make.ValDef(
@@ -637,7 +643,7 @@ public class DeSugarize implements Kinds, Modifiers {
/** add case constructor, value defintiions and access functions.
*/
- Tree[] addCaseElements(Tree[] body, ValDef[] vparams) {
+ public Tree[] addCaseElements(Tree[] body, ValDef[] vparams) {
TreeList stats = new TreeList();
for (int i = 0; i < vparams.length; i++) {
addCaseElement(stats, vparams[i]);
diff --git a/sources/scalac/typechecker/Infer.java b/sources/scalac/typechecker/Infer.java
index 29acd44100..d0feffd3ac 100644
--- a/sources/scalac/typechecker/Infer.java
+++ b/sources/scalac/typechecker/Infer.java
@@ -37,20 +37,20 @@ public class Infer implements Modifiers, Kinds {
// Error messages -------------------------------------------------------------
- String applyErrorMsg(String msg1, Tree fn,
+ public String applyErrorMsg(String msg1, Tree fn,
String msg2, Type[] argtypes, Type pt) {
return msg1 + toString(fn.symbol(), fn.type) + msg2 +
ArrayApply.toString(argtypes, "(", ",", ")") +
(pt == Type.AnyType ? "" : " with expected result type " + pt);
}
- String typeErrorMsg(String msg, Type found, Type req) {
+ public String typeErrorMsg(String msg, Type found, Type req) {
return msg +
";\n found : " + found.toLongString() +
"\n required: " + req;
}
- String overloadResolveErrorMsg(Symbol sym1, Type tpe1, Symbol sym2, Type tpe2) {
+ public String overloadResolveErrorMsg(Symbol sym1, Type tpe1, Symbol sym2, Type tpe2) {
return "ambiguous reference to overloaded definition,\n" +
"both " + sym1 + ": " + tpe1 + "\n" +
"and " + sym2 + ": " + tpe2 + "\nmatch";
@@ -59,7 +59,7 @@ public class Infer implements Modifiers, Kinds {
/** Give a string representation of symbol `sym' with type `tp'
* for error diagnostics. `sym' may be null.
*/
- static String toString(Symbol sym, Type tp) {
+ public String toString(Symbol sym, Type tp) {
return
(tp instanceof Type.OverloadedType ? "overloaded " : "") +
(sym == null ? "expression" : sym) + " of type " + tp;
@@ -395,7 +395,7 @@ public class Infer implements Modifiers, Kinds {
/** throw a type error if arguments not within bounds.
*/
- void checkBounds(Symbol[] tparams, Type[] targs, String prefix) {
+ public void checkBounds(Symbol[] tparams, Type[] targs, String prefix) {
if (!isWithinBounds(tparams, targs)) {
throw new Type.Error(
prefix + "type arguments " +
@@ -569,7 +569,7 @@ public class Infer implements Modifiers, Kinds {
/** Is normalized type `tp' a subtype of prototype `pt'?
*/
- boolean isCompatible(Type tp, Type pt) {
+ public boolean isCompatible(Type tp, Type pt) {
return normalize(tp).isSubType(pt);
}
@@ -736,7 +736,7 @@ public class Infer implements Modifiers, Kinds {
* are replaced by `AnyType's. We try to instantiate first to `pt1' and then,
* if this fails, to `pt2'. If both attempts fail, a Type.Error is thrown.
*/
- Type argumentTypeInstance(Symbol[] tparams, Type restype, Type pt1, Type pt2)
+ public Type argumentTypeInstance(Symbol[] tparams, Type restype, Type pt1, Type pt2)
throws Type.Error {
switch (restype) {
case PolyType(Symbol[] tparams1, Type restype1):
@@ -869,7 +869,7 @@ public class Infer implements Modifiers, Kinds {
/** Is function type `ftpe' applicable to `argtypes' and
* does its result conform to `pt'?
*/
- boolean isApplicable(Type ftpe, Type[] argtypes, Type pt) {
+ public boolean isApplicable(Type ftpe, Type[] argtypes, Type pt) {
switch (ftpe) {
case MethodType(Symbol[] params, Type restpe):
// sequences ? List( a* )