Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 public final class Main {
     18 
     19   /// CHECK-START: void Main.main(String[]) builder (after)
     20   /// CHECK: StaticFieldGet klass:Main[] exact: true
     21   /// CHECK: ArrayGet klass:Main exact:true
     22   /// CHECK: BoundType klass:Main exact:true
     23   public static void main(String[] args) {
     24     Object o = null;
     25     Main f = a[0];
     26     for (int i = 0; i < 2; ++i) {
     27       // We used to crash in the fixed point iteration of
     28       // the reference type propagation while handling the instanceof:
     29       // we were expecting `o` to get the same exact-ness as the
     30       // `HBoundType` but the typing of the `ArrayGet` used to not
     31       // propagate the exact-ness.
     32       if (o instanceof Main) {
     33         field = o;
     34       }
     35       o = f;
     36     }
     37     if (field != null) {
     38       throw new Error("Expected null");
     39     }
     40   }
     41 
     42   static Main[] a = new Main[1];
     43   static Object field;
     44 }
     45