Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8247569: [lworld] Align with spec for <vnew> methods #771

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -615,7 +615,7 @@ private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set<ClassSymbol>
}

MethodSymbol findConstructor(ClassSymbol tsym, List<Type> paramTypes, boolean strict) {
Name constructorName = tsym.isValueClass() ? names.vnew : names.init;
Name constructorName = tsym.isConcreteValueClass() ? names.vnew : names.init;
for (Symbol sym : tsym.members().getSymbolsByName(constructorName)) {
if (sym.kind == MTH) {
if (hasParameterTypes((MethodSymbol) sym, paramTypes, strict)) {
Original file line number Diff line number Diff line change
@@ -424,6 +424,10 @@ public boolean isValueClass() {
return !isInterface() && (flags() & VALUE_CLASS) != 0;
}

public boolean isConcreteValueClass() {
return isValueClass() && !isAbstract();
}

public boolean isIdentityClass() {
return !isInterface() && (flags() & IDENTITY_TYPE) != 0;
}
Original file line number Diff line number Diff line change
@@ -3541,7 +3541,7 @@ public Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) {
* LTM code is doing to look for type annotations so we are fine.
*/
if ((owner.flags() & STATIC) == 0) {
Name constructorName = owner.isValueClass() ? names.vnew : names.init;
Name constructorName = owner.isConcreteValueClass() ? names.vnew : names.init;
for (Symbol s : enclClass.members_field.getSymbolsByName(constructorName)) {
newScopeOwner = s;
break;
@@ -3608,7 +3608,7 @@ public void visitReference(final JCMemberReference that) {
Symbol lhsSym = TreeInfo.symbol(that.expr);
if (TreeInfo.isStaticSelector(that.expr, names)) {
// TODO - a bit hacky but...
if (lhsSym != null && lhsSym.isValueClass() && that.name == names.init) {
if (lhsSym != null && lhsSym.isConcreteValueClass() && that.name == names.init) {
that.name = names.vnew;
}
//if the qualifier is a type, validate it; raw warning check is
Original file line number Diff line number Diff line change
@@ -1662,7 +1662,7 @@ private Symbol initSym(ClassSymbol csym, long flags) {
return clinit;
} else {
//get the first constructor and treat it as the instance init sym
Name constructorName = csym.isValueClass() ? names.vnew : names.init;
Name constructorName = csym.isConcreteValueClass() ? names.vnew : names.init;
for (Symbol s : csym.members_field.getSymbolsByName(constructorName)) {
return s;
}
Original file line number Diff line number Diff line change
@@ -1264,7 +1264,7 @@ Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
argtypes = argtypes
.prepend(syms.intType)
.prepend(syms.stringType);
Name constructorName = accOwner.isValueClass() ? names.vnew : names.init;
Name constructorName = accOwner.isConcreteValueClass() ? names.vnew : names.init;
aconstr = new MethodSymbol(
SYNTHETIC,
constructorName,
Original file line number Diff line number Diff line change
@@ -180,7 +180,7 @@ void memberEnter(List<? extends JCTree> trees, Env<AttrContext> env) {

public void visitMethodDef(JCMethodDecl tree) {
WriteableScope enclScope = enter.enterScope(env);
if (tree.name == tree.name.table.names.init && allowValueClasses && enclScope.owner.isValueClass()) {
if (tree.name == tree.name.table.names.init && allowValueClasses && enclScope.owner.isConcreteValueClass()) {
tree.name = tree.name.table.names.vnew;
}
MethodSymbol m = new MethodSymbol(0, tree.name, null, enclScope.owner);
Original file line number Diff line number Diff line change
@@ -1055,7 +1055,7 @@ public void visitOpens(JCOpens tree) {
}

MethodSymbol noArgsConstructor(ClassSymbol tsym) {
Name constructorName = tsym.isValueClass() ? names.vnew : names.init;
Name constructorName = tsym.isConcreteValueClass() ? names.vnew : names.init;
for (Symbol sym : tsym.members().getSymbolsByName(constructorName)) {
MethodSymbol mSym = (MethodSymbol)sym;
if (mSym.params().isEmpty()) {
Original file line number Diff line number Diff line change
@@ -2927,7 +2927,7 @@ private Symbol resolveConstructor(MethodResolutionContext resolveContext,
Type site,
List<Type> argtypes,
List<Type> typeargtypes) {
Name constructorName = site.tsym.isValueClass() ? names.vnew : names.init;
Name constructorName = site.tsym.isConcreteValueClass() ? names.vnew : names.init;
return lookupMethod(env, pos, site.tsym, resolveContext, new BasicLookupHelper(constructorName, site, argtypes, typeargtypes) {
@Override
Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
@@ -2962,7 +2962,7 @@ Symbol findConstructor(DiagnosticPosition pos, Env<AttrContext> env,
List<Type> typeargtypes,
boolean allowBoxing,
boolean useVarargs) {
Name constructorName = site.tsym.isValueClass() ? names.vnew : names.init;
Name constructorName = site.tsym.isConcreteValueClass() ? names.vnew : names.init;
Symbol sym = findMethod(env, site,
constructorName, argtypes,
typeargtypes, allowBoxing,
@@ -2987,7 +2987,7 @@ Symbol resolveDiamond(DiagnosticPosition pos,
Type site,
List<Type> argtypes,
List<Type> typeargtypes) {
Name constructorName = allowValueClasses && site.tsym.isValueClass() ? names.vnew : names.init;
Name constructorName = allowValueClasses && site.tsym.isConcreteValueClass() ? names.vnew : names.init;
return lookupMethod(env, pos, site.tsym, resolveMethodCheck,
new BasicLookupHelper(constructorName, site, argtypes, typeargtypes) {
@Override
@@ -3051,7 +3051,7 @@ private Symbol findDiamond(Env<AttrContext> env,
boolean useVarargs) {
Symbol bestSoFar = methodNotFound;
TypeSymbol tsym = site.tsym.isInterface() ? syms.objectType.tsym : site.tsym;
Name constructorName = site.tsym.isValueClass() ? names.vnew : names.init;
Name constructorName = site.tsym.isConcreteValueClass() ? names.vnew : names.init;
for (final Symbol sym : tsym.members().getSymbolsByName(constructorName)) {
//- System.out.println(" e " + e.sym);
if (sym.kind == MTH &&
@@ -3696,7 +3696,7 @@ class ArrayConstructorReferenceLookupHelper extends ReferenceLookupHelper {
ArrayConstructorReferenceLookupHelper(JCMemberReference referenceTree, Type site, List<Type> argtypes,
List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
// TODO - array constructor will be <init>
super(referenceTree, site.tsym.isValueClass() ? names.vnew : names.init, site, argtypes, typeargtypes, maxPhase);
super(referenceTree, site.tsym.isConcreteValueClass() ? names.vnew : names.init, site, argtypes, typeargtypes, maxPhase);
}

@Override
@@ -3728,7 +3728,7 @@ class ConstructorReferenceLookupHelper extends ReferenceLookupHelper {

ConstructorReferenceLookupHelper(JCMemberReference referenceTree, Type site, List<Type> argtypes,
List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
super(referenceTree, site.tsym.isValueClass() ? names.vnew : names.init, site, argtypes, typeargtypes, maxPhase);
super(referenceTree, site.tsym.isConcreteValueClass() ? names.vnew : names.init, site, argtypes, typeargtypes, maxPhase);
if (site.isRaw()) {
this.site = new ClassType(site.getEnclosingType(), site.tsym.type.getTypeArguments(), site.tsym, site.getMetadata(), site.getFlavor());
needsInference = true;
Original file line number Diff line number Diff line change
@@ -1361,7 +1361,7 @@ public MethodSymbol constructorSymbol() {
} else {
flags = (owner().flags() & AccessFlags) | GENERATEDCONSTR;
}
Name constructorName = owner().isValueClass() ? names.vnew : names.init;
Name constructorName = owner().isConcreteValueClass() ? names.vnew : names.init;
constructorSymbol = new MethodSymbol(flags, constructorName,
constructorType(), owner());
}
Original file line number Diff line number Diff line change
@@ -428,20 +428,4 @@ private JCExpressionStatement chainedConstructorCall(JCMethodDecl md) {
}
return null;
}

private MethodSymbol getDefaultConstructor(Symbol klass) {
Name constructorName = klass.isValueClass() ? names.vnew : names.init;
for (Symbol method : klass.members().getSymbolsByName(constructorName, s->s.kind == MTH && s.type.getParameterTypes().size() == 0, LookupKind.NON_RECURSIVE)) {
return (MethodSymbol) method;
}
// class defines a non-nullary but no nullary constructor, fabricate a symbol.
MethodType dctorType = new MethodType(List.nil(),
klass.type,
List.nil(),
klass.type.tsym);
return new MethodSymbol(Flags.PUBLIC,
constructorName,
dctorType,
klass);
}
}