incremental java make: handle ambiguous resolution problems after constructor overloading (IDEA-223826)

GitOrigin-RevId: a59bbcd14330165c518991157503c0eb89297a18
This commit is contained in:
Eugene Zhuravlev
2019-10-02 12:29:21 +02:00
committed by intellij-monorepo-bot
parent a4ab89af44
commit cddc167959
12 changed files with 79 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
Cleaning output files:
out/production/AddOverloadingConstructor/A.class
End of files
Compiling files:
src/A.java
End of files
Cleaning output files:
out/production/AddOverloadingConstructor/ASub.class
out/production/AddOverloadingConstructor/C.class
End of files
Compiling files:
src/ASub.java
src/C.java
End of files

View File

@@ -0,0 +1,6 @@
public class A {
public A(String x) {
}
public A(Integer x) {
}
}

View File

@@ -0,0 +1,4 @@
public class A {
public A(String x) {
}
}

View File

@@ -0,0 +1,5 @@
public class ASub extends A {
public ASub(String s) {
super(s);
}
}

View File

@@ -0,0 +1,5 @@
public class C {
void f (){
A a = new A(null);
}
}

View File

@@ -0,0 +1,5 @@
public class D {
void f (){
A a = new ASub(null);
}
}

View File

@@ -0,0 +1,12 @@
Cleaning output files:
out/production/AddOverloadingMethod/A.class
End of files
Compiling files:
src/A.java
End of files
Cleaning output files:
out/production/AddOverloadingMethod/C.class
End of files
Compiling files:
src/C.java
End of files

View File

@@ -0,0 +1,6 @@
public class A {
void f (String x) {
}
void f (Integer x) {
}
}

View File

@@ -0,0 +1,4 @@
public class A {
void f (String x) {
}
}

View File

@@ -0,0 +1,5 @@
public class C {
void f (A a){
a.f(null);
}
}

View File

@@ -1266,7 +1266,7 @@ public class Mappings {
TIntHashSet propagated = null;
if (!m.isPrivate() && m.name != myInitName) {
if (!m.isPrivate()) {
if (oldItRef == null) {
oldItRef = new Ref<>(getClassReprByName(null, it.name)); // lazy init
}
@@ -1274,7 +1274,10 @@ public class Mappings {
if (oldIt == null || !myPresent.hasOverriddenMethods(oldIt, MethodRepr.equalByJavaRules(m), null)) {
if (m.myArgumentTypes.length > 0) {
propagated = myFuture.propagateMethodAccess(m, it.name);
if (m.name != myInitName) {
// do not propagate constructors access, since constructors are always concrete and not accessible via references to subclasses
propagated = myFuture.propagateMethodAccess(m, it.name);
}
debug("Conservative case on overriding methods, affecting method usages");
myFuture.affectMethodUsages(m, propagated, m.createMetaUsage(myContext, it.name), state.myAffectedUsages, state.myDependants);
}

View File

@@ -207,6 +207,14 @@ public class MemberChangeTest extends IncrementalTestCase {
doTest();
}
public void testAddOverloadingMethod() {
doTest();
}
public void testAddOverloadingConstructor() {
doTest();
}
public void testAddVarargMethod() {
doTest();
}