summaryrefslogtreecommitdiff
path: root/sources/scalac
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-04-04 18:37:59 +0000
committerpaltherr <paltherr@epfl.ch>2004-04-04 18:37:59 +0000
commit6b35acd807e982b5296eb05898561ea8664bf2a3 (patch)
tree4c39fe37f0dcd827eb7582eb0b4b564074b20acc /sources/scalac
parent8127c2eeeff7ee3a3f65a205020d50c4c5cdba16 (diff)
downloadscala-6b35acd807e982b5296eb05898561ea8664bf2a3.tar.gz
scala-6b35acd807e982b5296eb05898561ea8664bf2a3.tar.bz2
scala-6b35acd807e982b5296eb05898561ea8664bf2a3.zip
- Added method Type.isError
Diffstat (limited to 'sources/scalac')
-rw-r--r--sources/scalac/symtab/Type.java25
-rw-r--r--sources/scalac/symtab/classfile/CLRClassParser.java2
-rw-r--r--sources/scalac/typechecker/RefCheck.java4
3 files changed, 25 insertions, 6 deletions
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java
index 8fb835786b..bbd0455423 100644
--- a/sources/scalac/symtab/Type.java
+++ b/sources/scalac/symtab/Type.java
@@ -154,7 +154,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
"illegal cyclic reference involving " + rebind);
sym = rebind.rebindSym();
}
- if (pre.isStable() || pre == ErrorType) {
+ if (pre.isStable() || pre.isError()) {
return new ExtSingleType(pre, sym);
} else {
throw new Type.Malformed(pre, sym.nameString() + ".type");
@@ -197,7 +197,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
}
public static Type typeRef(Type pre, Symbol sym, Type[] args) {
- if (!pre.isLegalPrefix() && pre != ErrorType)
+ if (!pre.isLegalPrefix() && !pre.isError())
throw new Type.Malformed(pre, sym.nameString());
rebind:
if (sym.isAbstractType()) {
@@ -225,7 +225,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
return new ExtTypeRef(pre, sym, args);
}
private static boolean isLegalTypeRef(Type pre, Symbol sym, Type[] args) {
- if (!pre.isLegalPrefix() && pre != ErrorType) return false;
+ if (!pre.isLegalPrefix() && !pre.isError()) return false;
if (!sym.isType() && !sym.isError()) return false;
// !!! return args.length == 0 || args.length == sym.typeParams().length;
return true;
@@ -642,6 +642,25 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
// Tests --------------------------------------------------------------------
+ /** Is this type a an error type?
+ */
+ public boolean isError() {
+ switch (this) {
+ case ErrorType:
+ return true;
+ case ThisType(Symbol clasz):
+ return clasz.isError();
+ case SingleType(_, Symbol symbol):
+ return symbol.isError();
+ case TypeRef(_, Symbol symbol, _):
+ return symbol.isError();
+ case CompoundType(Type[] parts, Scope members):
+ return symbol().isError();
+ default:
+ return false;
+ }
+ }
+
/** Is this type a this type or singleton type?
*/
public boolean isStable() {
diff --git a/sources/scalac/symtab/classfile/CLRClassParser.java b/sources/scalac/symtab/classfile/CLRClassParser.java
index 8ac897cca5..0ec6df58a4 100644
--- a/sources/scalac/symtab/classfile/CLRClassParser.java
+++ b/sources/scalac/symtab/classfile/CLRClassParser.java
@@ -275,7 +275,7 @@ public class CLRClassParser extends SymbolLoader {
assert type != null;
scalac.symtab.Type res =
make.classType(type.FullName.replace('+', '.'));
- if (res == scalac.symtab.Type.ErrorType)
+ if (res.isError())
global.error("unknown class reference " + type.FullName);
return res;
}
diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java
index 92290a4317..c7e2572d72 100644
--- a/sources/scalac/typechecker/RefCheck.java
+++ b/sources/scalac/typechecker/RefCheck.java
@@ -277,7 +277,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds {
}
void overrideError(int pos, Symbol member, Symbol other, String msg) {
- if (other.type() != Type.ErrorType && member.type() != Type.ErrorType)
+ if (!other.type().isError() && !member.type().isError())
unit.error(pos,
"error overriding " + other + other.locationString() +
";\n " + member + member.locationString() + " " + msg);
@@ -285,7 +285,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds {
void overrideTypeError(int pos, Symbol member, Symbol other, Type site,
boolean lobound) {
- if (other.type() != Type.ErrorType && member.type() != Type.ErrorType) {
+ if (!other.type().isError() && !member.type().isError()) {
Type memberInfo = lobound ? site.memberLoBound(member)
: normalizedInfo(site, member);
Type otherInfo = lobound ? site.memberLoBound(other)