Exemple #1
0
  private KotlinBuiltIns() {
    builtInsModule =
        new ModuleDescriptorImpl(
            Name.special("<built-ins lazy module>"),
            Collections.<ImportPath>emptyList(),
            PlatformToKotlinClassMap.EMPTY);
    builtinsPackageFragment =
        new BuiltinsPackageFragment(
            BUILT_INS_PACKAGE_FQ_NAME,
            new LockBasedStorageManager(),
            builtInsModule,
            new Function1<String, InputStream>() {
              @Override
              public InputStream invoke(String path) {
                return KotlinBuiltIns.class.getClassLoader().getResourceAsStream(path);
              }
            });
    builtInsModule.initialize(builtinsPackageFragment.getProvider());
    builtInsModule.addDependencyOnModule(builtInsModule);
    builtInsModule.seal();

    primitiveTypeToNullableJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
    primitiveTypeToArrayJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
    primitiveJetTypeToJetArrayType = new HashMap<JetType, JetType>();
    jetArrayTypeToPrimitiveJetType = new HashMap<JetType, JetType>();
  }
 @NotNull
 public ClassDescriptor getAnnotationClassByName(@NotNull Name simpleName) {
   ClassifierDescriptor classifier =
       annotationPackageFragment
           .getMemberScope()
           .getContributedClassifier(simpleName, NoLookupLocation.FROM_BUILTINS);
   assert classifier instanceof ClassDescriptor
       : "Must be a class descriptor "
           + simpleName
           + ", but was "
           + (classifier == null ? "null" : classifier.toString());
   return (ClassDescriptor) classifier;
 }
 @NotNull
 public MemberScope getAnnotationPackageScope() {
   return annotationPackageFragment.getMemberScope();
 }
 @NotNull
 public MemberScope getBuiltInsPackageScope() {
   return builtinsPackageFragment.getMemberScope();
 }