-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate length information from argument to return value of Arrays.…
…copyOf() (#3524)
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Test case for https://tinyurl.com/cfissue/3224 | ||
|
||
import java.util.Arrays; | ||
import org.checkerframework.common.value.qual.IntRange; | ||
import org.checkerframework.common.value.qual.MinLen; | ||
|
||
public class Issue3224 { | ||
static class Arrays { | ||
static String[] copyOf(String[] args, int length) { | ||
return args; | ||
} | ||
} | ||
|
||
public static void m1(String @MinLen(1) [] args) { | ||
int i = 4; | ||
String @MinLen(1) [] args2 = java.util.Arrays.copyOf(args, i); | ||
} | ||
|
||
public static void m2(String @MinLen(1) [] args) { | ||
String @MinLen(1) [] args2 = java.util.Arrays.copyOf(args, args.length); | ||
} | ||
|
||
public static void m3(String @MinLen(1) ... args) { | ||
String @MinLen(1) [] args2 = java.util.Arrays.copyOf(args, args.length); | ||
} | ||
|
||
public static void m4(String @MinLen(1) [] args, @IntRange(from = 10, to = 200) int len) { | ||
String @MinLen(1) [] args2 = java.util.Arrays.copyOf(args, len); | ||
} | ||
|
||
public static void m5(String @MinLen(1) [] args, String[] otherArray) { | ||
// :: error: assignment.type.incompatible | ||
String @MinLen(1) [] args2 = java.util.Arrays.copyOf(args, otherArray.length); | ||
} | ||
|
||
public static void m6(String @MinLen(1) [] args) { | ||
// :: error: assignment.type.incompatible | ||
String @MinLen(1) [] args2 = Arrays.copyOf(args, args.length); | ||
} | ||
} |
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