Sort class members to ensure deterministic builds

Class methods and fields are currently sorted at serialization (see
DescriptorSerializer.sort) and at deserialization (see
DeserializedMemberScope.OptimizedImplementation#addMembers). Therefore,
the contents of the generated stub files are sorted in incremental
builds but not in clean builds.

The consequence is that the contents of the generated stub files may not
be consistent across a clean build and an incremental build, making the
build non-deterministic and dependent tasks run unnecessarily (see
KT-40882).

To work around that, this commit sorts class methods and fields when
outputting stub files.

Bug: KT-40882 (there are actually 2 issues in here; this commit fixes
     the first one)
Test: New DeterministicBuildIT + Updated existing test expectation files
This commit is contained in:
Hung Nguyen
2020-11-12 12:51:47 +00:00
committed by nataliya.valtman
parent 07a797cc3a
commit 4bf63a9539
70 changed files with 1380 additions and 1277 deletions
@@ -6,10 +6,10 @@ import java.lang.System;
public final class A$B {
public test.A$B.C c;
public test.A$B.D$E de;
public test.J$B.C jc;
public test.J$B.D$E jde;
public test.A$B.D$$E dee;
public test.A$B.D$$$E deee;
public test.J$B.C jc;
public test.J$B.D$E jde;
public test.J$B.D$$E jdee;
public test.J$B.D$$$E jdeee;
@@ -253,6 +253,11 @@ public final class Test1 extends test.Foo.Bar implements test.IFoo.IBar, test.IF
@org.jetbrains.annotations.NotNull()
private final test.Foo.Bar.Zoo zoo = null;
public Test1(@org.jetbrains.annotations.NotNull()
test.Foo.Bar.Zoo zoo) {
super();
}
@org.jetbrains.annotations.NotNull()
public final java.lang.Thread.State a() {
return null;
@@ -267,9 +272,4 @@ public final class Test1 extends test.Foo.Bar implements test.IFoo.IBar, test.IF
public final test.Foo.Bar.Zoo getZoo() {
return null;
}
public Test1(@org.jetbrains.annotations.NotNull()
test.Foo.Bar.Zoo zoo) {
super();
}
}