186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin/*
286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * Copyright (C) 2017 The Android Open Source Project
386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin *
486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * Licensed under the Apache License, Version 2.0 (the "License");
586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * you may not use this file except in compliance with the License.
686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * You may obtain a copy of the License at
786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin *
886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin *      http://www.apache.org/licenses/LICENSE-2.0
986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin *
1086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * Unless required by applicable law or agreed to in writing, software
1186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * distributed under the License is distributed on an "AS IS" BASIS,
1286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * See the License for the specific language governing permissions and
1486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin * limitations under the License.
1586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin */
1686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
1786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass A {}
1886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass B1 extends A {}
1986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass B2 extends A {}
2086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass C1 extends B1 {}
2186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass C2 extends B1 {}
2286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass D1 extends C1 {}
2386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass D2 extends C2 {}
2486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass E1 extends D1 {}
2586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass E2 extends D2 {}
2686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass F1 extends E1 {}
2786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass F2 extends E2 {}
2886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass G1 extends F1 {}
2986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinclass G2 extends F2 {}
3086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
3186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkinpublic class Main {
3286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin  public static void main(String[] args) {
3386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    String yes = "Yes";
3486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    String no = "No";
3586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
3686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A a = new A();
3786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A b1 = new B1();
3886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A b2 = new B2();
3986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A c1 = new C1();
4086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A c2 = new C2();
4186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A f1 = new F1();
4286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A f2 = new F2();
4386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A g1 = new G1();
4486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    A g2 = new G2();
4586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
4686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(b1 instanceof G1);
4786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectTrue(g1 instanceof B1);
4886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(b1 instanceof F1);
4986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectTrue(f1 instanceof B1);
5086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
5186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(b2 instanceof G1);
5286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(g1 instanceof B2);
5386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(b2 instanceof F1);
5486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(f1 instanceof B2);
5586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
5686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(g2 instanceof G1);
5786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(g1 instanceof G2);
5886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(f2 instanceof F1);
5986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(f1 instanceof F2);
6086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
6186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectTrue(g1 instanceof F1);
6286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(g1 instanceof F2);
6386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectFalse(g2 instanceof F1);
6486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    expectTrue(g2 instanceof F2);
6586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
6686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    System.out.println("passed");
6786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin  }
6886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
6986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin  private static void expectTrue(boolean value) {
7086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    if (!value) {
7186083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin      throw new Error("Expected True");
7286083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    }
7386083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin  }
7486083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin
7586083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin  private static void expectFalse(boolean value) {
7686083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    if (value) {
7786083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin      throw new Error("Expected False");
7886083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin    }
7986083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin  }
8086083f7cd118f3d6c757191e83b4e4abaabdc5d7Igor Murashkin}
81