-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fully qualify types in generic synthetic method return types #341
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4a2e8bc
fully qualify types in generic synthetic method return types
theron-wang 7d41afb
Handle wildcards
theron-wang d046c73
check if type argument is already fully qualified
theron-wang e3431b2
Merge branch 'main' of https://github.com/njit-jerse/specimin into me…
theron-wang a3037f4
test case + todo
theron-wang a43bf5a
change previous test case
theron-wang e9c1b14
fix test
theron-wang 62a2ca3
change comments
theron-wang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,5 @@ | |
"na-389": "PASS", | ||
"na-705": "PASS", | ||
"na-791a": "PASS", | ||
"na-791b": "FAIL" | ||
"na-791b": "PASS" | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/java/org/checkerframework/specimin/MethodReturnFullyQualifiedGenericTest.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,20 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that Specimin includes the fully qualified class name in generics when | ||
* generating a synthetic method. For example, if a return type is Bar<com.foo.Foo>, the actual | ||
* synthetic return type should be com.qualified.Bar<com.foo.Foo>. At this moment, we should expect | ||
* this test case to fail. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than "we should expect this test to fail", I would phrase this as "this test encodes Specimin's current behavior, which doesn't produce compilable output. If you break this test, it might not be a bad thing." |
||
*/ | ||
public class MethodReturnFullyQualifiedGenericTest { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"methodreturnfullyqualifiedgeneric", | ||
new String[] {"com/example/Simple.java"}, | ||
new String[] {"com.example.Simple#alreadyQualified()"}); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/test/java/org/checkerframework/specimin/MethodReturnGenericTest.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,23 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that Specimin includes the fully qualified class name in generics when | ||
* generating a synthetic method. For example, if a return type is Foo<Bar>, Specimin should always | ||
* generate the synthetic method return type as com.example.Foo<com.other.Bar>. | ||
*/ | ||
public class MethodReturnGenericTest { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"methodreturngeneric", | ||
new String[] {"com/example/Simple.java"}, | ||
new String[] { | ||
"com.example.Simple#foo()", | ||
"com.example.Simple#bar()", | ||
"com.example.Simple#baz()" | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/resources/methodreturnfullyqualifiedgeneric/expected/com/bar/Bar.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,8 @@ | ||
package com.bar; | ||
|
||
public class Bar<T> { | ||
|
||
public static com.bar.Bar<com.example.InOtherPackage2> getOtherPackage2() { | ||
throw new Error(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/resources/methodreturnfullyqualifiedgeneric/expected/com/example/Simple.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,10 @@ | ||
package com.example; | ||
|
||
import com.bar.Bar; | ||
|
||
public class Simple { | ||
|
||
public Bar<com.foo.InOtherPackage2> alreadyQualified() { | ||
return Bar.getOtherPackage2(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/resources/methodreturnfullyqualifiedgeneric/expected/com/foo/InOtherPackage2.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,4 @@ | ||
package com.foo; | ||
|
||
public class InOtherPackage2 { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/resources/methodreturnfullyqualifiedgeneric/input/com/example/Simple.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,9 @@ | ||
package com.example; | ||
|
||
import com.bar.Bar; | ||
|
||
public class Simple { | ||
public Bar<com.foo.InOtherPackage2> alreadyQualified() { | ||
return Bar.getOtherPackage2(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/resources/methodreturngeneric/expected/com/bar/Bar.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,16 @@ | ||
package com.bar; | ||
|
||
public class Bar<T> { | ||
|
||
public static com.bar.Bar<com.foo.InOtherPackage> getOtherPackage() { | ||
throw new Error(); | ||
} | ||
|
||
public static com.bar.Bar<com.example.InSamePackage> getSamePackage() { | ||
throw new Error(); | ||
} | ||
|
||
public static com.bar.Bar<Integer> getJavaLang() { | ||
throw new Error(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/resources/methodreturngeneric/expected/com/example/InSamePackage.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,4 @@ | ||
package com.example; | ||
|
||
public class InSamePackage { | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/resources/methodreturngeneric/expected/com/example/Simple.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,19 @@ | ||
package com.example; | ||
|
||
import com.bar.Bar; | ||
import com.foo.InOtherPackage; | ||
|
||
public class Simple { | ||
|
||
public Bar<InOtherPackage> foo() { | ||
return Bar.getOtherPackage(); | ||
} | ||
|
||
public Bar<InSamePackage> bar() { | ||
return Bar.getSamePackage(); | ||
} | ||
|
||
public Bar<Integer> baz() { | ||
return Bar.getJavaLang(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/resources/methodreturngeneric/expected/com/foo/InOtherPackage.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,4 @@ | ||
package com.foo; | ||
|
||
public class InOtherPackage { | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/resources/methodreturngeneric/input/com/example/Simple.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,18 @@ | ||
package com.example; | ||
|
||
import com.bar.Bar; | ||
import com.foo.InOtherPackage; | ||
|
||
public class Simple { | ||
public Bar<InOtherPackage> foo() { | ||
return Bar.getOtherPackage(); | ||
} | ||
|
||
public Bar<InSamePackage> bar() { | ||
return Bar.getSamePackage(); | ||
} | ||
|
||
public Bar<Integer> baz() { | ||
return Bar.getJavaLang(); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a reference to the test that demonstrates the "bad" behavior to this comment.