summaryrefslogtreecommitdiff
path: root/sources/scalac
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-08-11 14:16:55 +0000
committerMartin Odersky <odersky@gmail.com>2003-08-11 14:16:55 +0000
commitde98c6562ab6488d71abda1d3b1fcc2b078524de (patch)
tree604a6555e8ffdd486724acef3b0f96beae6c3e93 /sources/scalac
parentb515ce4596e857154c237d5b114dcd897701ca9b (diff)
downloadscala-de98c6562ab6488d71abda1d3b1fcc2b078524de.tar.gz
scala-de98c6562ab6488d71abda1d3b1fcc2b078524de.tar.bz2
scala-de98c6562ab6488d71abda1d3b1fcc2b078524de.zip
*** empty log message ***
Diffstat (limited to 'sources/scalac')
-rw-r--r--sources/scalac/symtab/Definitions.java8
-rw-r--r--sources/scalac/symtab/Symbol.java16
-rw-r--r--sources/scalac/symtab/classfile/PackageParser.java12
-rw-r--r--sources/scalac/symtab/classfile/Pickle.java2
-rw-r--r--sources/scalac/typechecker/Analyzer.java21
-rw-r--r--sources/scalac/typechecker/RefCheck.java8
-rw-r--r--sources/scalac/util/Names.java1
7 files changed, 47 insertions, 21 deletions
diff --git a/sources/scalac/symtab/Definitions.java b/sources/scalac/symtab/Definitions.java
index 9e269348c6..e8450ef265 100644
--- a/sources/scalac/symtab/Definitions.java
+++ b/sources/scalac/symtab/Definitions.java
@@ -67,6 +67,7 @@ public class Definitions {
public final Symbol EQEQ;
public final Symbol BANGEQ;
public final Symbol EQUALS;
+ public final Symbol EQ;
public final Symbol TOSTRING;
public final Symbol HASHCODE;
@@ -230,6 +231,7 @@ public class Definitions {
// the scala.ANYVAL class
ANYVAL_CLASS = getClass(Names.scala_AnyVal);
+ ANYVAL_CLASS.flags |= Modifiers.SEALED;
ANYVAL_TYPE = ANYVAL_CLASS.typeConstructor();
// the scala.ALL class
@@ -347,6 +349,12 @@ public class Definitions {
BOOLEAN_TYPE));
ANY_CLASS.members().enter(EQUALS);
+ EQ = new TermSymbol(
+ Position.NOPOS, Names.eq, ANY_CLASS, 0);
+ EQ.setInfo(Type.MethodType(new Symbol[]{newParameter(EQ, JAVA_OBJECT_TYPE)},
+ BOOLEAN_TYPE));
+ ANY_CLASS.members().enter(EQ);
+
TOSTRING = new TermSymbol(
Position.NOPOS, Names.toString, ANY_CLASS, 0);
TOSTRING.setInfo(Type.MethodType(Symbol.EMPTY_ARRAY, STRING_TYPE));
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 18b14c087d..751aa93863 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -399,18 +399,18 @@ public abstract class Symbol implements Modifiers, Kinds {
return isConstructor() && this == primaryConstructorClass().primaryConstructor();
}
- public boolean isGenerated() {
+ public final boolean isGenerated() {
return name.pos((byte)'$') < name.length();
}
/** Symbol was preloaded from package
*/
- public boolean isPreloaded() {
+ public final boolean isExternal() {
return pos == Position.NOPOS;
}
/** Is this symbol an overloaded symbol? */
- public boolean isOverloaded() {
+ public final boolean isOverloaded() {
switch (info()) {
case OverloadedType(_,_): return true;
default : return false;
@@ -418,7 +418,7 @@ public abstract class Symbol implements Modifiers, Kinds {
}
/** Does this symbol denote a label? */
- public boolean isLabel() {
+ public final boolean isLabel() {
return (flags & LABEL) != 0;
}
@@ -1020,7 +1020,7 @@ public class TermSymbol extends Symbol {
public static TermSymbol define(
int pos, Name name, Symbol owner, int flags, Scope scope) {
Scope.Entry e = scope.lookupEntry(name);
- if (e.owner == scope && e.sym.pos == Position.NOPOS && e.sym.kind == VAL) {
+ if (e.owner == scope && e.sym.isExternal() && e.sym.kind == VAL) {
TermSymbol sym = (TermSymbol) e.sym;
sym.update(pos, flags);
return sym;
@@ -1145,7 +1145,7 @@ public class TypeSymbol extends Symbol {
public static TypeSymbol define(
int pos, Name name, Symbol owner, int flags, Scope scope) {
Scope.Entry e = scope.lookupEntry(name);
- if (e.owner == scope && e.sym.pos == Position.NOPOS && e.sym.kind == ALIAS) {
+ if (e.owner == scope && e.sym.isExternal() && e.sym.kind == ALIAS) {
TypeSymbol sym = (TypeSymbol) e.sym;
sym.update(pos, flags);
return sym;
@@ -1316,7 +1316,7 @@ public class AbsTypeSymbol extends TypeSymbol {
public static AbsTypeSymbol define(
int pos, Name name, Symbol owner, int flags, Scope scope) {
Scope.Entry e = scope.lookupEntry(name);
- if (e.owner == scope && e.sym.pos == Position.NOPOS && e.sym.kind == TYPE) {
+ if (e.owner == scope && e.sym.isExternal() && e.sym.kind == TYPE) {
AbsTypeSymbol sym = (AbsTypeSymbol) e.sym;
sym.update(pos, flags);
return sym;
@@ -1401,7 +1401,7 @@ public class ClassSymbol extends TypeSymbol {
public static ClassSymbol define(
int pos, Name name, Symbol owner, int flags, Scope scope) {
Scope.Entry e = scope.lookupEntry(name);
- if (e.owner == scope && e.sym.pos == Position.NOPOS && e.sym.kind == CLASS) {
+ if (e.owner == scope && e.sym.isExternal() && e.sym.kind == CLASS) {
ClassSymbol sym = (ClassSymbol) e.sym;
sym.update(pos, flags);
sym.template = null;
diff --git a/sources/scalac/symtab/classfile/PackageParser.java b/sources/scalac/symtab/classfile/PackageParser.java
index 1b29c7a0ef..9d62fb1009 100644
--- a/sources/scalac/symtab/classfile/PackageParser.java
+++ b/sources/scalac/symtab/classfile/PackageParser.java
@@ -66,11 +66,13 @@ public class PackageParser extends Type.LazyType {
if (previous == Symbol.NONE || previous.isPackage()) return true;
if (previous.pos != Position.NOPOS) return false;
AbstractFile pf = (AbstractFile) symFile.get(previous);
- if (!global.separate) {
- if (f.getName().endsWith(".scala") &&
- pf.getName().endsWith(".class")) return true;
- if (f.getName().endsWith(".class") &&
- pf.getName().endsWith(".scala")) return false;
+ if (f.getName().endsWith(".scala")) {
+ if (pf.getName().endsWith(".scala")) return false;
+ if (!global.separate) return true;
+ }
+ if (f.getName().endsWith(".class")) {
+ if (pf.getName().endsWith(".class")) return false;
+ if (!global.separate) return false;
}
return f.lastModified() > pf.lastModified();
}
diff --git a/sources/scalac/symtab/classfile/Pickle.java b/sources/scalac/symtab/classfile/Pickle.java
index bae101668d..ec75241842 100644
--- a/sources/scalac/symtab/classfile/Pickle.java
+++ b/sources/scalac/symtab/classfile/Pickle.java
@@ -46,7 +46,7 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
/** Pickle all symbols descending from `root'.
*/
public void add(Symbol root) {
- if (root.pos != Position.NOPOS) {
+ if (!root.isExternal()) {
if (Global.instance.debug) System.out.println("pickling " + root);
if (index.get(root) == null) {
this.rootname = root.name.toTermName();
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index 3c3812c573..519cb58c7e 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -13,7 +13,9 @@
// todo: emit warnings for unchecked.
// todo: synchronize on module instantiation.
// todo: type select operator for superclass term access.
-
+// todo: implement EQ
+// todo: for (Tuplen(...) <- ...)
+// todo: empty package
package scalac.typechecker;
@@ -211,7 +213,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
else return "value " + NameTransformer.decode(name);
}
- /** Check that `sym' accessible as a member of tree `site' in current context.
+ /** Check that `sym' is accessible as a member of tree `site' in current context.
*/
void checkAccessible(int pos, Symbol sym, Tree site) {
if (!isAccessible(sym, site)) {
@@ -815,7 +817,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
if (sym == other) {
if (global.debug) global.log("redefined: " + sym + ":" + sym.rawInfo());
} else if (e.owner == context.scope) {
- if (other.isPreloaded()) {
+ if (other.isExternal()) {
assert false : sym + " " + other;
// symbol was preloaded from package;
// need to overwrite definition.
@@ -1378,7 +1380,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
pre = Type.localThisType;
}
}
- } else if (sym.kind != NONE && !sym.isPreloaded()) {
+ } else if (sym.kind != NONE && !sym.isExternal()) {
return error(tree.pos,
"reference to " + name + " is ambiguous;\n" +
"it is both defined in " + sym.owner() +
@@ -1547,7 +1549,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Symbol c = f.primaryConstructorClass();
if (c.kind == CLASS) {
c.initialize();//to detect cycles
- if (i > 0 && (c.flags & JAVA) == 0 && c.pos == Position.NOPOS) {
+ if (i > 0 && (c.flags & JAVA) == 0 && c.isExternal()) {
// need to load tree for mixins
new SourceCompleter(global).complete(c);
}
@@ -1943,7 +1945,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Tree applyVisitor = transformVisitor(tree, pattype, restype);
if (!infer.isFullyDefined(restype))
restype = applyVisitor.type;
- if (definitions.PARTIALFUNCTION_CLASS.pos == Position.NOPOS)
+ if (definitions.PARTIALFUNCTION_CLASS.isExternal())
// need to load tree for mixins
new SourceCompleter(global).complete(
definitions.PARTIALFUNCTION_CLASS);
@@ -2249,7 +2251,12 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
case Ident(Name name):
if (name == Names.this_.toTypeName()) {
- return transform(make.Ident(tree.pos, pt.symbol().name));
+ Tree tree1 = transform(make.Ident(tree.pos, pt.symbol().name));
+ Symbol constr = tree1.symbol();
+ if (constr != null && constr.kind == VAL && constr.pos > tree.pos)
+ error(tree.pos,
+ "illegal forward reference to self constructor");
+ return tree1;
} else if (((mode & (PATTERNmode | FUNmode)) == PATTERNmode) &&
name.isVariable()) {
diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java
index 3b5b9f7d78..00279759ec 100644
--- a/sources/scalac/typechecker/RefCheck.java
+++ b/sources/scalac/typechecker/RefCheck.java
@@ -136,6 +136,14 @@ public class RefCheck extends Transformer implements Modifiers, Kinds {
overrideError(pos, member, other, "needs `override' modifier");
} else if (other.isStable() && !member.isStable()) {
overrideError(pos, member, other, "needs to be an immutable value");
+ } else if ((member.flags & DEFERRED) == 0 && (other.flags & DEFERRED) == 0 &&
+ member.owner() != clazz &&
+ !clazz.parents()[0].symbol().isSubClass(other.owner())) {
+ unit.error(pos, "conflict between concrete members " +
+ member + member.locationString() + " and " +
+ other + other.locationString() +
+ ":\n both are inherited from mixin classes; " +
+ "\n an overriding definition in the current template is required");
} else {
Type self = clazz.thisType();
switch (other.kind) {
diff --git a/sources/scalac/util/Names.java b/sources/scalac/util/Names.java
index c059218230..8c7ecdb5c4 100644
--- a/sources/scalac/util/Names.java
+++ b/sources/scalac/util/Names.java
@@ -131,6 +131,7 @@ public class Names {
public static final Name scala_Unit = Name.fromString("scala.Unit");
public static final Name scala_runtime = Name.fromString("scala.runtime");
public static final Name scala_runtime_RunTime = Name.fromString("scala.runtime.RunTime");
+ public static final Name eq = Name.fromString("eq");
public static final Name equals = Name.fromString("equals");
public static final Name toString = Name.fromString("toString");
public static final Name that = Name.fromString("that");