Skip to content

Commit

Permalink
Remove explicit "implements Object" from classes; it is implicit
Browse files Browse the repository at this point in the history
  • Loading branch information
cpurdy committed Jul 26, 2023
1 parent 773394f commit fee2073
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
25 changes: 19 additions & 6 deletions javatools/src/main/java/org/xvm/asm/constants/TypeConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -2475,8 +2475,6 @@ private TypeConstant[] createContributionList(
switch (struct.getFormat())
{
case PACKAGE:
assert cContribs != 0 || ((PackageStructure) struct).isModuleImport();
// fall through
case MODULE:
case ENUMVALUE:
case ENUM:
Expand All @@ -2490,8 +2488,8 @@ private TypeConstant[] createContributionList(
// format)
typeRebase = (TypeConstant) pool.register(struct.getRebaseType());

// next up, for any class type (other than Object itself), there may be an "extends"
// contribution that specifies another class
// next up, for any class type, there may be an "extends" contribution that
// specifies a "super" class
Contribution contrib = iContrib < cContribs ? listContribs.get(iContrib) : null;
boolean fExtends = contrib != null && contrib.getComposition() == Composition.Extends;

Expand All @@ -2501,6 +2499,9 @@ private TypeConstant[] createContributionList(
{
log(errs, Severity.ERROR, VE_EXTENDS_EXPECTED, constId.getPathString());
}

// a class hierarchy root implicitly implements the root Object interface
++cContribs;
break;
}

Expand Down Expand Up @@ -2671,8 +2672,20 @@ else if (!fInto)
// the list to do
for ( ; iContrib < cContribs; ++iContrib)
{
Contribution contrib = listContribs.get(iContrib);
TypeConstant typeContrib = aContribType[iContrib];
Contribution contrib;
TypeConstant typeContrib;
if (iContrib < listContribs.size())
{
contrib = listContribs.get(iContrib);
typeContrib = aContribType[iContrib];
}
else
{
// it's the implicit "implements Object" contribution
assert iContrib == listContribs.size();
typeContrib = pool.typeObject();
contrib = struct.new Contribution(Composition.Implements, typeContrib);
}

switch (contrib.getComposition())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ else if ((nSpecified & nBits) != 0)
// interface n [8] n [8] n [9]
//
// [1] module/package/const/enum may explicitly extend a class or a const; otherwise
// implements Object
// implements Object (implicit: "Object" is not added to the structure)
// [2] package may import a module
// [3] class may explicitly extend a class; otherwise implements Object (the one exception is
// Object itself, which does NOT implement itself)
Expand Down Expand Up @@ -1002,7 +1002,8 @@ else if ((nSpecified & nBits) != 0)
break;

default:
typeDefaultImpl = pool.typeObject();
// it's implied that the default impl is pool.typeObject()
typeDefaultImpl = null;
break;
}
}
Expand Down

0 comments on commit fee2073

Please sign in to comment.