Skip to content
Permalink
Browse files
8244563: [lworld] Javac does not allow jlO to be express superclass o…
…f inline types.
  • Loading branch information
Srikanth Adayapalam committed May 15, 2020
1 parent 122aa79 commit c82e6b9815e50ece6f474b86390f85d1e0f9ced8
Showing 6 changed files with 8 additions and 11 deletions.
@@ -743,11 +743,10 @@ private Object asTypeParam(Type t) {
}

void checkConstraintsOfInlineSuper(DiagnosticPosition pos, ClassSymbol c) {
boolean indirectSuper = false;
for(Type st = types.supertype(c.type); st != Type.noType; indirectSuper = true, st = types.supertype(st)) {
for(Type st = types.supertype(c.type); st != Type.noType; st = types.supertype(st)) {
if (st == null || st.tsym == null || st.tsym.kind == ERR)
return;
if (indirectSuper && st.tsym == syms.objectType.tsym)
if (st.tsym == syms.objectType.tsym)
return;
if (!st.tsym.isAbstract()) {
log.error(pos, Errors.ConcreteSupertypeForInlineClass(c, st));
@@ -1,8 +1,8 @@
/*
* @test /nodynamiccopyright/
* @summary Values may not extend
* @summary Values may not extend a concrete type other than jlO
*
* @compile/fail/ref=CheckExtends.out -XDallowEmptyValues -XDrawDiagnostics CheckExtends.java
* @compile/fail/ref=CheckExtends.out -XDrawDiagnostics CheckExtends.java
*/

final inline class CheckExtends extends Object {
@@ -1,2 +1,2 @@
CheckExtends.java:8:14: compiler.err.concrete.supertype.for.inline.class: CheckExtends, java.lang.Object
CheckExtends.java:8:14: compiler.err.empty.value.not.yet
1 error
@@ -1,4 +1,3 @@
InlineAnnotationTest.java:25:1: compiler.err.illegal.combination.of.modifiers: interface, inline
InlineAnnotationTest.java:9:1: compiler.err.concrete.supertype.for.inline.class: InlineAnnotationTest01, java.lang.Object
InlineAnnotationTest.java:20:9: compiler.err.cant.assign.val.to.final.var: x
3 errors
2 errors
@@ -12,7 +12,7 @@ public class SuperclassConstraints {
// Test that super class cannot be concrete, including express jlO
static class BadSuper {}
inline class I0 extends BadSuper {} // ERROR: concrete super class
inline class I1 extends Object {} // ERROR: concrete jlO cannot be express-superclass
inline class I1 extends Object {} // OK: concrete jlO can be express-superclass
inline class I2 {} // OK

// Test that abstract class is allowed to be super including when extending jlO
@@ -1,9 +1,8 @@
SuperclassConstraints.java:14:12: compiler.err.inline.type.must.not.implement.identity.object: SuperclassConstraints.I0
SuperclassConstraints.java:15:12: compiler.err.concrete.supertype.for.inline.class: SuperclassConstraints.I1, java.lang.Object
SuperclassConstraints.java:44:12: compiler.err.super.field.not.allowed: x, SuperclassConstraints.I6, SuperclassConstraints.SuperWithInstanceField
SuperclassConstraints.java:76:12: compiler.err.super.no.arg.constructor.must.be.empty: SuperclassConstraints.SuperWithNonEmptyNoArgCtor(), SuperclassConstraints.I9, SuperclassConstraints.SuperWithNonEmptyNoArgCtor
SuperclassConstraints.java:85:12: compiler.err.super.constructor.cannot.take.arguments: SuperclassConstraints.SuperWithArgedCtor(java.lang.String), SuperclassConstraints.I10, SuperclassConstraints.SuperWithArgedCtor
SuperclassConstraints.java:98:12: compiler.err.super.class.declares.init.block: SuperclassConstraints.I11, SuperclassConstraints.SuperWithInstanceInit
SuperclassConstraints.java:106:12: compiler.err.super.method.cannot.be.synchronized: foo(), SuperclassConstraints.I12, SuperclassConstraints.SuperWithSynchronizedMethod
SuperclassConstraints.java:110:12: compiler.err.super.class.cannot.be.inner: SuperclassConstraints.I13, SuperclassConstraints.InnerSuper
8 errors
7 errors

0 comments on commit c82e6b9

Please sign in to comment.