From fd4e74823ef61bdd8cd8eaffff03e62f6becd087 Mon Sep 17 00:00:00 2001 From: schinz Date: Thu, 7 Apr 2005 19:47:48 +0000 Subject: - accept the creation of compound types with no... - accept the creation of compound types with non-empty refinements, but fail as soon as isSameType/isSubType is attempted --- sources/scala/runtime/types/CompoundType.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sources/scala/runtime/types/CompoundType.java b/sources/scala/runtime/types/CompoundType.java index 662d46cfa5..18b8f8deb6 100644 --- a/sources/scala/runtime/types/CompoundType.java +++ b/sources/scala/runtime/types/CompoundType.java @@ -24,13 +24,11 @@ import scala.runtime.RunTime; public class CompoundType extends Type { public final ClassType[] components; + public final boolean emptyRefinement; public CompoundType(ClassType[] components, boolean emptyRefinement) { this.components = components; - - if (!emptyRefinement) - throw new Error("attempt to build a compound type with " - + "non-empty refinement"); + this.emptyRefinement = emptyRefinement; } public Array newArray(int size) { @@ -52,8 +50,12 @@ public class CompoundType extends Type { } public boolean isSubType(Type that) { + if (!emptyRefinement) + throw new Error("cannot compute isSubType (non-empty refinement)"); + if (that instanceof CompoundType) { - ClassType[] thatComponents = ((CompoundType)that).components; + CompoundType thatCT = (CompoundType)that; + ClassType[] thatComponents = thatCT.components; for (int i = 0; i < thatComponents.length; ++i) { if (!this.isSubType(thatComponents[i])) return false; @@ -69,6 +71,9 @@ public class CompoundType extends Type { } public boolean isSameType(Type that) { + if (!emptyRefinement) + throw new Error("cannot compute isSameType (non-empty refinement)"); + if (that instanceof CompoundType) { CompoundType thatCT = (CompoundType)that; -- cgit v1.2.3