-
Notifications
You must be signed in to change notification settings - Fork 29
Fix viewpoint-adapted varargs type #903
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
base: master
Are you sure you want to change the base?
Changes from 7 commits
5d3c189
df8a262
8228faa
56dde2f
eb4e7c0
c2b1bf1
0d9cde6
d6adf2e
bffeb0d
5a2db67
465269b
be684d3
5192106
f073243
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Test case for EISOP issue #386: | ||
| // https://github.com/eisop/checker-framework/issues/386 | ||
| import viewpointtest.quals.*; | ||
|
|
||
| public class Issue386 { | ||
| public class Inner { | ||
| Inner() {} | ||
|
|
||
| Inner(@ReceiverDependentQual Object... args) {} | ||
| } | ||
|
|
||
| public class MethodReceiver { | ||
| void method(@ReceiverDependentQual Object... args) {} | ||
| } | ||
|
|
||
| @SuppressWarnings("cast.unsafe.constructor.invocation") | ||
| public void constructorTest(@A Object aObj, @A Object otherAObj, @B Object bObj) { | ||
| this.new @A Inner(aObj, otherAObj); | ||
| // :: error: (argument.type.incompatible) | ||
| this.new @A Inner(aObj, bObj); | ||
| } | ||
|
|
||
| public void methodTest( | ||
| @A MethodReceiver receiver, @A Object aObj, @A Object otherAObj, @B Object bObj) { | ||
| receiver.method(aObj, otherAObj); | ||
| // :: error: (argument.type.incompatible) | ||
|
aosen-xiong marked this conversation as resolved.
|
||
| receiver.method(aObj, bObj); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,8 @@ void foo() { | |
| void invokeConstructor(@A Object aObj, @B Object bObj, @Top Object topObj) { | ||
| @A Object a = new @A VarargsConstructor(aObj); | ||
| @B Object b = new @B VarargsConstructor(bObj); | ||
| // :: error: (argument.type.incompatible) :: error: (new.class.type.invalid) | ||
| // :: error: (argument.type.incompatible) :: error: (new.class.type.invalid) :: error: | ||
| // (varargs.type.incompatible) | ||
| @Top Object top = new @Top VarargsConstructor(topObj); | ||
| // :: error: (argument.type.incompatible) | ||
| new @A VarargsConstructor(bObj); | ||
|
|
@@ -30,7 +31,7 @@ class Inner { | |
| @ReceiverDependentQual Inner(@ReceiverDependentQual Object... args) {} | ||
|
|
||
| void foo() { | ||
| // :: error: (new.class.type.invalid) | ||
| // :: error: (new.class.type.invalid) :: error: (varargs.type.incompatible) | ||
|
Member
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. What is the intuition behind this new error? There are no arguments to this constructor invocation, so what is incompatible?
Collaborator
Author
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. The err msg is: A zero-argument varargs invocation still creates an implicit empty array. The error occurs because viewpoint adaptation produces
Member
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. What is the connection to #1173? 1173 is about lost receivers for poly declared receiver methods. This is about arrays? If the var args array is definitely empty, the Lost component type cannot do any harm. It seems overly conservative to forbid this call, doesn't it?
Collaborator
Author
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. Because in #1173 we changed Lost to be a subtype of Lost, this Okay, I see your points. I think even after the change in #1173, we should have
|
||
| Inner a = new Inner(); | ||
| // :: warning: (cast.unsafe.constructor.invocation) | ||
| Inner b = new @A Inner(new @A Object()); | ||
|
|
@@ -42,7 +43,8 @@ void foo() { | |
| void invokeConstructor(@A Object aObj, @B Object bObj, @Top Object topObj) { | ||
| @A Object a = new @A Inner(aObj); | ||
| @B Object b = new @B Inner(bObj); | ||
| // :: error: (argument.type.incompatible) :: error: (new.class.type.invalid) | ||
| // :: error: (argument.type.incompatible) :: error: (new.class.type.invalid) :: error: | ||
| // (varargs.type.incompatible) | ||
| @Top Object top = new @Top Inner(topObj); | ||
| // :: error: (argument.type.incompatible) | ||
| new @A Inner(bObj); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.