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

8244233: [lworld] Nested types are not handled properly across projections #141

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -2187,8 +2187,10 @@ public boolean overrides(Symbol _other, TypeSymbol origin, Types types, boolean
if (origin.isValue())
origin = (TypeSymbol) origin.referenceProjection();

if (this.owner.isValue())
return this.projection.overrides(_other, origin, types, checkResult, requireConcreteIfInherited);
if (this.owner.isValue()) {
return this.projection != null &&
this.projection.overrides(_other, origin, types, checkResult, requireConcreteIfInherited);
}

if (this == _other) return true;
MethodSymbol other = (MethodSymbol)_other;
@@ -418,6 +418,11 @@ public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym, boolean
sym = sym.referenceProjection();
if (env.enclClass.sym.isValue())
env.enclClass.sym = env.enclClass.sym.referenceProjection();
} else if (sym.kind == TYP) {
// A type is accessible in a reference projection if it was
// accessible in the value projection.
if (site.isReferenceProjection())
site = site.valueProjection();
}
try {
switch ((short)(sym.flags() & AccessFlags)) {
@@ -2200,6 +2205,10 @@ Symbol findImmediateMemberType(Env<AttrContext> env,
Type site,
Name name,
TypeSymbol c) {
// ATM, inner/nested types are members of only the declaring inline class,
// although accessible via the reference projection.
if (c.isReferenceProjection())
c = (TypeSymbol) c.valueProjection();
for (Symbol sym : c.members().getSymbolsByName(name)) {
if (sym.kind == TYP) {
return isAccessible(env, site, sym)
@@ -0,0 +1,21 @@
/**
* @test /nodynamiccopyright/
* @bug 8244233
* @summary Nested types are not handled properly across projections
* @compile/fail/ref=DualPathInnerType.out -XDrawDiagnostics DualPathInnerType.java
*/

public inline class DualPathInnerType {

class Inner { }

static DualPathInnerType.Inner xi = new DualPathInnerType().new Inner();
DualPathInnerType.ref.Inner xri = xi;

void f (DualPathInnerType.Inner xri) {}
void f (DualPathInnerType.ref.Inner xri) {}

public static void main(String [] args) {
new DualPathInnerType();
}
}
@@ -0,0 +1,2 @@
DualPathInnerType.java:16:10: compiler.err.already.defined: kindname.method, f(DualPathInnerType.Inner), kindname.class, DualPathInnerType
1 error
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8244233
* @summary Nested types are not handled properly across projections
* @run main/othervm ValueAsEnclosingClass
*/

public inline class ValueAsEnclosingClass {

static inline class V {
int y = 52;

class Bar { }
static class Baz { }
}

class Inner { }

static ValueAsEnclosingClass.Inner xi = new ValueAsEnclosingClass().new Inner();
ValueAsEnclosingClass.ref.Inner xri = xi;

public static void main(String[] args) {
new V().new Bar();
V.Baz baz1 = new V.Baz();
V.ref.Baz baz2 = baz1;
new ValueAsEnclosingClass();
}
}