diff --git a/infer/tests/codetoanalyze/java/litho/Column.java b/infer/tests/codetoanalyze/java/litho/Column.java index 228a0d10e..b63386004 100644 --- a/infer/tests/codetoanalyze/java/litho/Column.java +++ b/infer/tests/codetoanalyze/java/litho/Column.java @@ -41,5 +41,10 @@ public class Column extends Component { public Column build() { return mColumn; } + + @Override + public Builder getThis() { + return this; + } } } diff --git a/infer/tests/codetoanalyze/java/litho/Component.java b/infer/tests/codetoanalyze/java/litho/Component.java index 593047e3f..a72ae84b9 100644 --- a/infer/tests/codetoanalyze/java/litho/Component.java +++ b/infer/tests/codetoanalyze/java/litho/Component.java @@ -9,8 +9,14 @@ package com.facebook.litho; public class Component { - public abstract static class Builder { + public abstract static class Builder> { public abstract Component build(); + + public abstract T getThis(); + + public T commonProp(Object prop) { + return getThis(); + } } } diff --git a/infer/tests/codetoanalyze/java/litho/RequiredProps.java b/infer/tests/codetoanalyze/java/litho/RequiredProps.java index 900558249..b6218feba 100644 --- a/infer/tests/codetoanalyze/java/litho/RequiredProps.java +++ b/infer/tests/codetoanalyze/java/litho/RequiredProps.java @@ -31,7 +31,7 @@ class MyComponent extends Component { return new Builder(); } - static class Builder extends Component.Builder { + static class Builder extends Component.Builder { MyComponent mMyComponent; public Builder prop1(Object o) { @@ -52,6 +52,11 @@ class MyComponent extends Component { public MyComponent build() { return mMyComponent; } + + @Override + public Builder getThis() { + return this; + } } } @@ -64,7 +69,7 @@ class MyTreeComponent extends Component { return new Builder(); } - static class Builder extends Component.Builder { + static class Builder extends Component.Builder { MyTreeComponent mMyTreeComponent; public Builder prop1(Object o) { @@ -75,6 +80,11 @@ class MyTreeComponent extends Component { public MyTreeComponent build() { return mMyTreeComponent; } + + @Override + public Builder getThis() { + return this; + } } } @@ -91,7 +101,7 @@ class ResPropComponent extends Component { return new Builder(); } - static class Builder extends Component.Builder { + static class Builder extends Component.Builder { ResPropComponent mResPropComponent; @@ -128,6 +138,11 @@ class ResPropComponent extends Component { public ResPropComponent build() { return mResPropComponent; } + + @Override + public Builder getThis() { + return this; + } } } @@ -141,7 +156,7 @@ class VarArgPropComponent extends Component { return new Builder(); } - static class Builder extends Component.Builder { + static class Builder extends Component.Builder { VarArgPropComponent mVarArgPropComponent; @@ -194,6 +209,11 @@ class VarArgPropComponent extends Component { public VarArgPropComponent build() { return mVarArgPropComponent; } + + @Override + public Builder getThis() { + return this; + } } } @@ -227,6 +247,15 @@ public class RequiredProps { return mMyComponent.create().prop1(new Object()).prop2(new Object()).build(); } + public Component buildWithCommonPropOk() { + return mMyComponent + .create() + .prop1(new Object()) + .commonProp(new Object()) + .prop3(new Object()) + .build(); + } + private static MyComponent.Builder setProp1(MyComponent.Builder builder) { return builder.prop1(new Object()); }