-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from Ladicek/signature-parser-fix
Fix wrong type parameter sharing in generic signature parser
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
core/src/test/java/org/jboss/jandex/test/SignatureSharingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.jboss.jandex.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.Iterator; | ||
|
||
import org.jboss.jandex.ClassInfo; | ||
import org.jboss.jandex.DotName; | ||
import org.jboss.jandex.Index; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class SignatureSharingTest { | ||
public interface WithMethodSignature { | ||
<E extends Runnable> E method(E arg); | ||
} | ||
|
||
public interface WithClassSignature<E extends Exception> extends Iterator<E> { | ||
} | ||
|
||
@Test | ||
public void classSignatureOnly() throws Exception { | ||
test(Index.of(WithClassSignature.class)); | ||
} | ||
|
||
@Test | ||
public void classSignatureBeforeMethodSignature() throws Exception { | ||
test(Index.of(WithClassSignature.class, WithMethodSignature.class)); | ||
} | ||
|
||
@Test | ||
public void classSignatureAfterMethodSignature() throws Exception { | ||
test(Index.of(WithMethodSignature.class, WithClassSignature.class)); | ||
} | ||
|
||
private void test(Index index) { | ||
ClassInfo clazz = index.getClassByName(WithClassSignature.class); | ||
DotName bound = clazz.interfaceTypes().get(0).asParameterizedType() // Iterator<E> | ||
.arguments().get(0).asTypeVariable() // E | ||
.bounds().get(0).asClassType().name(); // E's bound | ||
|
||
assertEquals(DotName.createSimple(Exception.class.getName()), bound); | ||
} | ||
} |