-
Bug
-
Resolution: Fixed
-
P4
-
11.0.1, 15
-
b27
Test file:
~~~
class C {
private C(int x) {}
private C(String x) {}
}
class Test {
C c = new C(0);
}
~~~
% -> `javahome 15`/bin/javac C.java
C.java:7: error: incompatible types: int cannot be converted to String
C c = new C(0);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Obviously the most relevant problem is that C(int) is private, not that C(String) has an incompatible type.
Reordering the declarations prompts the expected output:
~~~
class C {
private C(String x) {}
private C(int x) {}
}
class Test {
C c = new C(0);
}
~~~
% -> `javahome 15`/bin/javac C.java
C.java:7: error: C(int) has private access in C
C c = new C(0);
^
1 error
~~~
class C {
private C(int x) {}
private C(String x) {}
}
class Test {
C c = new C(0);
}
~~~
% -> `javahome 15`/bin/javac C.java
C.java:7: error: incompatible types: int cannot be converted to String
C c = new C(0);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Obviously the most relevant problem is that C(int) is private, not that C(String) has an incompatible type.
Reordering the declarations prompts the expected output:
~~~
class C {
private C(String x) {}
private C(int x) {}
}
class Test {
C c = new C(0);
}
~~~
% -> `javahome 15`/bin/javac C.java
C.java:7: error: C(int) has private access in C
C c = new C(0);
^
1 error