From d8a3d0acaa3ff4bae5a20ff64d265754e7c1fbe5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 2 Sep 2003 17:27:57 +0000 Subject: *** empty log message *** --- sources/scalac/ast/parser/Parser.java | 1 + sources/scalac/symtab/Definitions.java | 2 -- sources/scalac/symtab/Symbol.java | 5 +++++ sources/scalac/transformer/UnCurry.java | 7 ++++--- sources/scalac/typechecker/Analyzer.java | 11 ++++++----- 5 files changed, 16 insertions(+), 10 deletions(-) (limited to 'sources/scalac') diff --git a/sources/scalac/ast/parser/Parser.java b/sources/scalac/ast/parser/Parser.java index 7a6cd2b3db..7206114a39 100644 --- a/sources/scalac/ast/parser/Parser.java +++ b/sources/scalac/ast/parser/Parser.java @@ -1671,6 +1671,7 @@ public class Parser implements Tokens { return ts.toArray(); case OBJECT: case CASEOBJECT: + if (s.token == CASEOBJECT) mods |= Modifiers.CASE; do { s.nextToken(); ts.append(objectDef(mods)); diff --git a/sources/scalac/symtab/Definitions.java b/sources/scalac/symtab/Definitions.java index 7a33403004..e9f000b848 100644 --- a/sources/scalac/symtab/Definitions.java +++ b/sources/scalac/symtab/Definitions.java @@ -236,8 +236,6 @@ public class Definitions { // the scala.ANYVAL class ANYVAL_CLASS = getClass(Names.scala_AnyVal); - ANYVAL_CLASS.initialize(); - ANYVAL_CLASS.flags |= Modifiers.SEALED; ANYVAL_TYPE = ANYVAL_CLASS.typeConstructor(); // the scala.ALL class diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index 04eff30d3a..5acaec4dee 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -255,6 +255,11 @@ public abstract class Symbol implements Modifiers, Kinds { return (flags & FINAL) != 0; } + /** Does this symbol denote a sealed class symbol? */ + public final boolean isSealed() { + return (flags & SEALED) != 0; + } + /** Does this symbol denote a method? */ public final boolean isInitializedMethod() { diff --git a/sources/scalac/transformer/UnCurry.java b/sources/scalac/transformer/UnCurry.java index 3cae85252a..6294631ce5 100644 --- a/sources/scalac/transformer/UnCurry.java +++ b/sources/scalac/transformer/UnCurry.java @@ -53,7 +53,8 @@ public class UnCurry extends OwnerTransformer case MethodType(_, _): return tree; default: - return tree.setType(Type.MethodType(Symbol.EMPTY_ARRAY, tree.type)); + return tree.setType( + Type.MethodType(Symbol.EMPTY_ARRAY, tree.type.widen())); } } @@ -145,7 +146,7 @@ public class UnCurry extends OwnerTransformer default: if (tree1.symbol().isDefParameter()) { tree1.type = global.definitions.functionType( - Type.EMPTY_ARRAY, tree1.type); + Type.EMPTY_ARRAY, tree1.type.widen()); return gen.Apply(gen.Select(tree1, Names.apply), new Tree[0]); } else { return tree1; @@ -214,7 +215,7 @@ public class UnCurry extends OwnerTransformer } } return transform( - gen.mkUnitFunction(arg, descr.uncurry(arg.type), currentOwner)); + gen.mkUnitFunction(arg, descr.uncurry(arg.type.widen()), currentOwner)); } else { return transform(arg); } diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java index 8cf7347498..2c887c9393 100644 --- a/sources/scalac/typechecker/Analyzer.java +++ b/sources/scalac/typechecker/Analyzer.java @@ -368,7 +368,8 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { } if ((bsym.flags & FINAL) != 0) { error(constrs[i].pos, "illegal inheritance from final class"); - } else if ((bsym.flags & SEALED) != 0) { + } else if (bsym.isSealed() || + bsym.isSubClass(definitions.ANYVAL_CLASS)) { // are we in same scope as base type definition? Scope.Entry e = context.scope.lookupEntry(bsym.name); if (e.sym != bsym || e.owner != context.scope) { @@ -1248,12 +1249,12 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { if (seqtp != Type.NoType) { tree.type = seqConstructorType(seqtp, pt); } else { - error(tree.pos, "expected pattern type " + pt + - " does not conform to sequence " + clazz); + return error(tree.pos, "expected pattern type " + pt + + " does not conform to sequence " + clazz); } } else if (tree.type != Type.ErrorType) { - error(tree.pos, tree.type.symbol() + - " is neither a case class constructor nor a sequence class constructor"); + return error(tree.pos, tree.type.symbol() + + " is neither a case class constructor nor a sequence class constructor"); } } if ((mode & FUNmode) != 0) { -- cgit v1.2.3