Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -1272,14 +1272,8 @@ public void visitClass(final ClassNode node) {

//

Map<GenericsTypeName, GenericsType> outerNames = null;
if (node instanceof InnerClassNode) {
outerNames = genericParameterNames;
if (!(node instanceof InnerClassNode) || Modifier.isStatic(node.getModifiers())) {
genericParameterNames = new HashMap<>();
if (!Modifier.isStatic(node.getModifiers()))
genericParameterNames.putAll(outerNames); // outer names visible
} else {
genericParameterNames.clear(); // outer class: new generic namespace
}
resolveGenericsHeader(node.getGenericsTypes());
switch (phase) { // GROOVY-9866, GROOVY-10466
Expand Down Expand Up @@ -1322,7 +1316,6 @@ public void visitClass(final ClassNode node) {
visitObjectInitializerStatements(node);
visitAnnotations(node); // GROOVY-10750, GROOVY-11206
}
if (outerNames != null) genericParameterNames = outerNames;
currentClass = oldNode;
}

Expand Down
19 changes: 0 additions & 19 deletions src/test/groovy/gls/innerClass/InnerClassTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1265,25 +1265,6 @@ final class InnerClassTest {
assert err =~ /No enclosing instance passed in constructor call of a non-static inner class/
}

// GROOVY-11711
@Test
void testUsageOfOuterType6() {
assertScript '''
class Foo<T> {
static class Bar {
}
/*non-static*/ class Baz
implements java.util.concurrent.Callable<T> {
T call() {
}
}
}
def foo = new Foo<Short>()
def baz = new Foo.Baz(foo)
assert baz.call() == null
'''
}

@Test
void testClassOutputOrdering() {
// this does actually not do much, but before this
Expand Down
33 changes: 33 additions & 0 deletions src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,39 @@ final class GroovyScriptEngineReloadingTest {

}

@Test
void testRecompilingWithGenericsAndConstants() {
MapFileSystem.instance.modFile('BaseClass.groovy', 'class BaseClass<T> {}', gse.@time)

def tertiaryClassText = '''
class NotGeneric {
/**
* Not typed on purpose - if typed as String then NotGeneric is no longer a dependency of
* ParameterisedClass for some reason...
*/
public static final Object CONSTANT = "not generic"
}
'''
MapFileSystem.instance.modFile('NotGeneric.groovy', tertiaryClassText, gse.@time)

def subClassText = '''
class SubClass extends BaseClass<String> {
public static final String CONSTANT = NotGeneric.CONSTANT
}
'''
MapFileSystem.instance.modFile('SubClass.groovy', subClassText, gse.@time)

MapFileSystem.instance.modFile('scriptUsingGeneric.groovy', 'SubClass.CONSTANT', gse.@time)


gse.loadScriptByName('scriptUsingGeneric.groovy')
sleep 1000

// make a change to the sub-class so that it gets recompiled
MapFileSystem.instance.modFile('SubClass.groovy', subClassText + '\n', gse.@time)
gse.loadScriptByName('scriptUsingGeneric.groovy')
}

@Test
void testDeleteDependent() {
sleep 10000
Expand Down
Loading