puppet 4.5.3-universal-darwin → 4.6.1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (422) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -1
  3. data/ext/debian/control +2 -4
  4. data/ext/project_data.yaml +4 -4
  5. data/install.rb +6 -2
  6. data/lib/puppet.rb +3 -1
  7. data/lib/puppet/agent/locker.rb +1 -1
  8. data/lib/puppet/application.rb +6 -4
  9. data/lib/puppet/application/agent.rb +2 -1
  10. data/lib/puppet/application/cert.rb +35 -2
  11. data/lib/puppet/application/device.rb +1 -1
  12. data/lib/puppet/application/generate.rb +5 -0
  13. data/lib/puppet/application/lookup.rb +3 -3
  14. data/lib/puppet/application_support.rb +1 -1
  15. data/lib/puppet/compilable_resource_type.rb +15 -0
  16. data/lib/puppet/configurer.rb +67 -10
  17. data/lib/puppet/configurer/plugin_handler.rb +2 -4
  18. data/lib/puppet/data_providers/hiera_config.rb +1 -1
  19. data/lib/puppet/defaults.rb +34 -7
  20. data/lib/puppet/environments.rb +4 -2
  21. data/lib/puppet/error.rb +1 -1
  22. data/lib/puppet/external/dot.rb +1 -1
  23. data/lib/puppet/face/ca.rb +4 -1
  24. data/lib/puppet/face/certificate.rb +7 -1
  25. data/lib/puppet/face/epp.rb +5 -5
  26. data/lib/puppet/face/generate.rb +64 -0
  27. data/lib/puppet/face/help.rb +19 -13
  28. data/lib/puppet/face/man.rb +1 -1
  29. data/lib/puppet/feature/external_facts.rb +1 -1
  30. data/lib/puppet/file_system.rb +16 -0
  31. data/lib/puppet/file_system/file_impl.rb +5 -0
  32. data/lib/puppet/file_system/memory_impl.rb +4 -0
  33. data/lib/puppet/file_system/path_pattern.rb +1 -0
  34. data/lib/puppet/file_system/windows.rb +19 -0
  35. data/lib/puppet/functions.rb +3 -5
  36. data/lib/puppet/functions/assert_type.rb +1 -1
  37. data/lib/puppet/functions/defined.rb +7 -5
  38. data/lib/puppet/functions/dig.rb +2 -18
  39. data/lib/puppet/functions/hiera.rb +1 -1
  40. data/lib/puppet/functions/lest.rb +1 -37
  41. data/lib/puppet/functions/new.rb +2 -473
  42. data/lib/puppet/functions/reverse_each.rb +2 -59
  43. data/lib/puppet/functions/scanf.rb +4 -4
  44. data/lib/puppet/functions/step.rb +1 -63
  45. data/lib/puppet/functions/then.rb +1 -61
  46. data/lib/puppet/functions/type.rb +1 -40
  47. data/lib/puppet/functions/unwrap.rb +40 -0
  48. data/lib/puppet/generate/models/type/property.rb +70 -0
  49. data/lib/puppet/generate/models/type/type.rb +57 -0
  50. data/lib/puppet/generate/templates/type/pcore.erb +41 -0
  51. data/lib/puppet/generate/type.rb +239 -0
  52. data/lib/puppet/graph/simple_graph.rb +2 -6
  53. data/lib/puppet/indirector/catalog/static_compiler.rb +5 -2
  54. data/lib/puppet/indirector/facts/facter.rb +1 -1
  55. data/lib/puppet/indirector/key/ca.rb +2 -2
  56. data/lib/puppet/indirector/request.rb +25 -4
  57. data/lib/puppet/indirector/rest.rb +73 -3
  58. data/lib/puppet/info_service/class_information_service.rb +1 -2
  59. data/lib/puppet/interface/documentation.rb +1 -1
  60. data/lib/puppet/loaders.rb +2 -0
  61. data/lib/puppet/metatype/manager.rb +6 -6
  62. data/lib/puppet/module.rb +8 -1
  63. data/lib/puppet/module_tool.rb +2 -2
  64. data/lib/puppet/module_tool/checksums.rb +1 -1
  65. data/lib/puppet/module_tool/errors/installer.rb +2 -2
  66. data/lib/puppet/module_tool/metadata.rb +1 -1
  67. data/lib/puppet/network/http/api/indirected_routes.rb +23 -32
  68. data/lib/puppet/network/http/rack/rest.rb +15 -1
  69. data/lib/puppet/network/rights.rb +1 -11
  70. data/lib/puppet/node/environment.rb +7 -3
  71. data/lib/puppet/node/facts.rb +1 -1
  72. data/lib/puppet/parameter.rb +23 -3
  73. data/lib/puppet/parameter/boolean.rb +1 -1
  74. data/lib/puppet/parameter/value.rb +1 -1
  75. data/lib/puppet/parser.rb +0 -1
  76. data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
  77. data/lib/puppet/parser/ast/resource.rb +5 -0
  78. data/lib/puppet/parser/ast/resource_instance.rb +5 -1
  79. data/lib/puppet/parser/ast/resourceparam.rb +5 -0
  80. data/lib/puppet/parser/compiler.rb +14 -17
  81. data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +1 -1
  82. data/lib/puppet/parser/environment_compiler.rb +10 -0
  83. data/lib/puppet/parser/functions/create_resources.rb +39 -24
  84. data/lib/puppet/parser/functions/defined.rb +2 -26
  85. data/lib/puppet/parser/functions/dig.rb +29 -0
  86. data/lib/puppet/parser/functions/lest.rb +49 -0
  87. data/lib/puppet/parser/functions/new.rb +530 -0
  88. data/lib/puppet/parser/functions/require.rb +1 -1
  89. data/lib/puppet/parser/functions/reverse_each.rb +83 -0
  90. data/lib/puppet/parser/functions/scanf.rb +4 -4
  91. data/lib/puppet/parser/functions/step.rb +84 -0
  92. data/lib/puppet/parser/functions/then.rb +73 -0
  93. data/lib/puppet/parser/functions/type.rb +53 -0
  94. data/lib/puppet/parser/resource.rb +16 -7
  95. data/lib/puppet/parser/scope.rb +36 -28
  96. data/lib/puppet/parser/type_loader.rb +1 -1
  97. data/lib/puppet/plugins/data_providers/data_provider.rb +1 -1
  98. data/lib/puppet/pops.rb +13 -0
  99. data/lib/puppet/pops/adapters.rb +49 -49
  100. data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +1 -1
  101. data/lib/puppet/pops/evaluator/access_operator.rb +39 -2
  102. data/lib/puppet/pops/evaluator/closure.rb +39 -13
  103. data/lib/puppet/pops/evaluator/collector_transformer.rb +10 -1
  104. data/lib/puppet/pops/evaluator/evaluator_impl.rb +16 -11
  105. data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
  106. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +0 -1
  107. data/lib/puppet/pops/evaluator/literal_evaluator.rb +0 -1
  108. data/lib/puppet/pops/evaluator/relationship_operator.rb +1 -2
  109. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +119 -0
  110. data/lib/puppet/pops/evaluator/runtime3_support.rb +19 -45
  111. data/lib/puppet/pops/functions/function.rb +5 -0
  112. data/lib/puppet/pops/issues.rb +1 -1
  113. data/lib/puppet/pops/label_provider.rb +2 -2
  114. data/lib/puppet/pops/loader/base_loader.rb +12 -15
  115. data/lib/puppet/pops/loader/loader.rb +15 -50
  116. data/lib/puppet/pops/loader/loader_paths.rb +28 -2
  117. data/lib/puppet/pops/loader/module_loaders.rb +16 -1
  118. data/lib/puppet/pops/loader/null_loader.rb +17 -1
  119. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +12 -11
  120. data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +80 -0
  121. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +2 -3
  122. data/lib/puppet/pops/loader/runtime3_type_loader.rb +52 -13
  123. data/lib/puppet/pops/loader/static_loader.rb +55 -0
  124. data/lib/puppet/pops/loader/type_definition_instantiator.rb +30 -14
  125. data/lib/puppet/pops/loader/typed_name.rb +50 -0
  126. data/lib/puppet/pops/loaders.rb +64 -19
  127. data/lib/puppet/pops/merge_strategy.rb +7 -7
  128. data/lib/puppet/pops/migration/migration_checker.rb +4 -0
  129. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  130. data/lib/puppet/pops/parser/egrammar.ra +8 -5
  131. data/lib/puppet/pops/parser/eparser.rb +1550 -1498
  132. data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
  133. data/lib/puppet/pops/parser/interpolation_support.rb +7 -0
  134. data/lib/puppet/pops/parser/lexer2.rb +14 -1
  135. data/lib/puppet/pops/parser/locator.rb +30 -1
  136. data/lib/puppet/pops/parser/parser_support.rb +0 -3
  137. data/lib/puppet/pops/parser/slurp_support.rb +3 -3
  138. data/lib/puppet/pops/patterns.rb +9 -1
  139. data/lib/puppet/pops/pcore.rb +67 -11
  140. data/lib/puppet/pops/puppet_stack.rb +43 -0
  141. data/lib/puppet/pops/resource/param.rb +51 -0
  142. data/lib/puppet/pops/resource/resource_type_impl.rb +301 -0
  143. data/lib/puppet/pops/resource/resource_type_set.pcore +21 -0
  144. data/lib/puppet/pops/serialization.rb +17 -0
  145. data/lib/puppet/pops/serialization/abstract_reader.rb +149 -0
  146. data/lib/puppet/pops/serialization/abstract_writer.rb +179 -0
  147. data/lib/puppet/pops/serialization/deserializer.rb +60 -0
  148. data/lib/puppet/pops/serialization/extension.rb +126 -0
  149. data/lib/puppet/pops/serialization/instance_reader.rb +19 -0
  150. data/lib/puppet/pops/serialization/instance_writer.rb +14 -0
  151. data/lib/puppet/pops/serialization/json.rb +247 -0
  152. data/lib/puppet/pops/serialization/object.rb +63 -0
  153. data/lib/puppet/pops/serialization/rgen.rb +151 -0
  154. data/lib/puppet/pops/serialization/serializer.rb +91 -0
  155. data/lib/puppet/pops/serialization/time_factory.rb +66 -0
  156. data/lib/puppet/pops/types/annotatable.rb +36 -0
  157. data/lib/puppet/pops/types/implementation_registry.rb +3 -8
  158. data/lib/puppet/pops/types/p_meta_type.rb +83 -0
  159. data/lib/puppet/pops/types/p_object_type.rb +110 -117
  160. data/lib/puppet/pops/types/p_runtime_type.rb +13 -0
  161. data/lib/puppet/pops/types/p_sem_ver_range_type.rb +23 -0
  162. data/lib/puppet/pops/types/p_sem_ver_type.rb +30 -2
  163. data/lib/puppet/pops/types/p_sensitive_type.rb +69 -0
  164. data/lib/puppet/pops/types/p_type_set_type.rb +361 -0
  165. data/lib/puppet/pops/types/puppet_object.rb +0 -5
  166. data/lib/puppet/pops/types/ruby_generator.rb +9 -2
  167. data/lib/puppet/pops/types/type_calculator.rb +6 -1
  168. data/lib/puppet/pops/types/type_factory.rb +14 -12
  169. data/lib/puppet/pops/types/type_formatter.rb +78 -33
  170. data/lib/puppet/pops/types/type_mismatch_describer.rb +0 -2
  171. data/lib/puppet/pops/types/type_parser.rb +27 -2
  172. data/lib/puppet/pops/types/type_set_reference.rb +59 -0
  173. data/lib/puppet/pops/types/types.rb +366 -13
  174. data/lib/puppet/pops/validation.rb +4 -4
  175. data/lib/puppet/pops/validation/checker4_0.rb +5 -2
  176. data/lib/puppet/pops/visitor.rb +2 -2
  177. data/lib/puppet/property.rb +64 -5
  178. data/lib/puppet/provider.rb +1 -1
  179. data/lib/puppet/provider/aixobject.rb +3 -3
  180. data/lib/puppet/provider/group/aix.rb +4 -4
  181. data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
  182. data/lib/puppet/provider/mailalias/aliases.rb +1 -1
  183. data/lib/puppet/provider/mcx/mcxcontent.rb +2 -2
  184. data/lib/puppet/provider/mount/parsed.rb +1 -1
  185. data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
  186. data/lib/puppet/provider/package/appdmg.rb +3 -3
  187. data/lib/puppet/provider/package/apple.rb +1 -1
  188. data/lib/puppet/provider/package/dnf.rb +5 -0
  189. data/lib/puppet/provider/package/nim.rb +1 -1
  190. data/lib/puppet/provider/package/pacman.rb +2 -2
  191. data/lib/puppet/provider/package/pip.rb +5 -3
  192. data/lib/puppet/provider/package/pip3.rb +1 -1
  193. data/lib/puppet/provider/package/pkg.rb +5 -5
  194. data/lib/puppet/provider/package/pkgdmg.rb +4 -4
  195. data/lib/puppet/provider/package/pkgin.rb +1 -1
  196. data/lib/puppet/provider/package/pkgutil.rb +1 -1
  197. data/lib/puppet/provider/package/portage.rb +48 -8
  198. data/lib/puppet/provider/package/sun.rb +1 -1
  199. data/lib/puppet/provider/package/tdnf.rb +28 -0
  200. data/lib/puppet/provider/package/yum.rb +22 -4
  201. data/lib/puppet/provider/parsedfile.rb +2 -2
  202. data/lib/puppet/provider/service/base.rb +1 -1
  203. data/lib/puppet/provider/service/bsd.rb +1 -1
  204. data/lib/puppet/provider/service/daemontools.rb +2 -2
  205. data/lib/puppet/provider/service/debian.rb +3 -3
  206. data/lib/puppet/provider/service/init.rb +5 -3
  207. data/lib/puppet/provider/service/launchd.rb +16 -2
  208. data/lib/puppet/provider/service/runit.rb +1 -1
  209. data/lib/puppet/provider/service/smf.rb +8 -1
  210. data/lib/puppet/provider/service/systemd.rb +39 -6
  211. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  212. data/lib/puppet/provider/user/aix.rb +3 -2
  213. data/lib/puppet/provider/user/directoryservice.rb +4 -3
  214. data/lib/puppet/provider/user/hpux.rb +1 -1
  215. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  216. data/lib/puppet/provider/user/windows_adsi.rb +3 -0
  217. data/lib/puppet/provider/zfs/zfs.rb +1 -1
  218. data/lib/puppet/reference/type.rb +1 -1
  219. data/lib/puppet/resource.rb +33 -7
  220. data/lib/puppet/resource/capability_finder.rb +74 -54
  221. data/lib/puppet/resource/status.rb +11 -2
  222. data/lib/puppet/settings.rb +17 -6
  223. data/lib/puppet/settings/environment_conf.rb +1 -1
  224. data/lib/puppet/settings/server_list_setting.rb +20 -0
  225. data/lib/puppet/ssl/certificate_authority.rb +32 -9
  226. data/lib/puppet/ssl/certificate_authority/interface.rb +164 -24
  227. data/lib/puppet/ssl/host.rb +3 -3
  228. data/lib/puppet/ssl/oids.rb +10 -0
  229. data/lib/puppet/ssl/validator/default_validator.rb +2 -2
  230. data/lib/puppet/test/test_helper.rb +2 -2
  231. data/lib/puppet/transaction.rb +12 -0
  232. data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
  233. data/lib/puppet/transaction/event.rb +29 -2
  234. data/lib/puppet/transaction/event_manager.rb +1 -1
  235. data/lib/puppet/transaction/persistence.rb +84 -0
  236. data/lib/puppet/transaction/report.rb +49 -2
  237. data/lib/puppet/transaction/resource_harness.rb +98 -18
  238. data/lib/puppet/type.rb +63 -21
  239. data/lib/puppet/type/augeas.rb +3 -3
  240. data/lib/puppet/type/cron.rb +1 -1
  241. data/lib/puppet/type/file.rb +39 -2
  242. data/lib/puppet/type/file/data_sync.rb +13 -5
  243. data/lib/puppet/type/host.rb +1 -1
  244. data/lib/puppet/type/mount.rb +2 -6
  245. data/lib/puppet/type/notify.rb +1 -1
  246. data/lib/puppet/type/package.rb +1 -1
  247. data/lib/puppet/type/resources.rb +1 -1
  248. data/lib/puppet/type/scheduled_task.rb +1 -1
  249. data/lib/puppet/type/ssh_authorized_key.rb +2 -2
  250. data/lib/puppet/type/tidy.rb +1 -1
  251. data/lib/puppet/type/yumrepo.rb +3 -3
  252. data/lib/puppet/type/zone.rb +1 -1
  253. data/lib/puppet/util.rb +2 -2
  254. data/lib/puppet/util/classgen.rb +1 -1
  255. data/lib/puppet/util/command_line.rb +6 -2
  256. data/lib/puppet/util/command_line/trollop.rb +1 -1
  257. data/lib/puppet/util/execution.rb +2 -2
  258. data/lib/puppet/util/http_proxy.rb +1 -1
  259. data/lib/puppet/util/inifile.rb +1 -1
  260. data/lib/puppet/util/instance_loader.rb +1 -1
  261. data/lib/puppet/util/logging.rb +1 -1
  262. data/lib/puppet/util/multi_match.rb +1 -1
  263. data/lib/puppet/util/plist.rb +15 -5
  264. data/lib/puppet/util/profiler.rb +1 -1
  265. data/lib/puppet/util/profiler/around_profiler.rb +1 -1
  266. data/lib/puppet/util/psych_support.rb +1 -1
  267. data/lib/puppet/util/rdoc.rb +2 -2
  268. data/lib/puppet/util/rubygems.rb +1 -1
  269. data/lib/puppet/util/watcher/periodic_watcher.rb +2 -2
  270. data/lib/puppet/util/windows/access_control_entry.rb +1 -1
  271. data/lib/puppet/util/windows/adsi.rb +30 -8
  272. data/lib/puppet/util/windows/api_types.rb +1 -1
  273. data/lib/puppet/util/windows/file.rb +59 -0
  274. data/lib/puppet/util/windows/process.rb +10 -0
  275. data/lib/puppet/util/windows/security.rb +1 -1
  276. data/lib/puppet/util/windows/user.rb +22 -4
  277. data/lib/puppet/util/yaml.rb +15 -3
  278. data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +1 -1
  279. data/lib/puppet/vendor/rgen_patch.rb +1 -1
  280. data/lib/puppet/version.rb +2 -2
  281. data/spec/fixtures/unit/pops/loaders/loaders/no_modules/manifests/site.pp +10 -0
  282. data/spec/integration/agent/logging_spec.rb +15 -14
  283. data/spec/integration/application/apply_spec.rb +1 -0
  284. data/spec/integration/directory_environments_spec.rb +16 -0
  285. data/spec/integration/environments/settings_spec.rb +32 -4
  286. data/spec/integration/faces/documentation_spec.rb +1 -1
  287. data/spec/integration/network/http/api/indirected_routes_spec.rb +33 -0
  288. data/spec/integration/node/environment_spec.rb +21 -0
  289. data/spec/integration/parser/collection_spec.rb +10 -0
  290. data/spec/integration/parser/compiler_spec.rb +76 -840
  291. data/spec/integration/parser/functions/require_spec.rb +3 -3
  292. data/spec/integration/parser/parameter_defaults_spec.rb +6 -2
  293. data/spec/integration/parser/pcore_resource_spec.rb +208 -0
  294. data/spec/integration/parser/resource_expressions_spec.rb +4 -2
  295. data/spec/integration/provider/yumrepo_spec.rb +4 -1
  296. data/spec/integration/transaction/report_spec.rb +666 -0
  297. data/spec/integration/type/file_spec.rb +11 -12
  298. data/spec/integration/util/windows/adsi_spec.rb +99 -0
  299. data/spec/integration/util/windows/principal_spec.rb +109 -60
  300. data/spec/integration/util/windows/process_spec.rb +4 -2
  301. data/spec/integration/util/windows/security_spec.rb +34 -8
  302. data/spec/integration/util/windows/user_spec.rb +26 -4
  303. data/spec/lib/puppet_spec/files.rb +2 -2
  304. data/spec/lib/puppet_spec/network.rb +12 -8
  305. data/spec/shared_examples/rhel_package_provider.rb +341 -0
  306. data/spec/spec_helper.rb +8 -2
  307. data/spec/unit/application/cert_spec.rb +20 -0
  308. data/spec/unit/configurer/plugin_handler_spec.rb +0 -26
  309. data/spec/unit/configurer_spec.rb +46 -0
  310. data/spec/unit/defaults_spec.rb +14 -0
  311. data/spec/unit/face/generate_spec.rb +230 -0
  312. data/spec/unit/face/help_spec.rb +53 -0
  313. data/spec/unit/face/parser_spec.rb +6 -0
  314. data/spec/unit/face/plugin_spec.rb +0 -4
  315. data/spec/unit/file_system_spec.rb +85 -0
  316. data/spec/unit/functions/lookup_spec.rb +4 -4
  317. data/spec/unit/functions/match_spec.rb +2 -2
  318. data/spec/unit/functions/regsubst_spec.rb +1 -1
  319. data/spec/unit/functions/split_spec.rb +1 -1
  320. data/spec/unit/functions/unwrap_spec.rb +29 -0
  321. data/spec/unit/functions/versioncmp_spec.rb +1 -1
  322. data/spec/unit/functions4_spec.rb +8 -8
  323. data/spec/unit/indirector/facts/facter_spec.rb +1 -9
  324. data/spec/unit/indirector/rest_spec.rb +95 -9
  325. data/spec/unit/module_spec.rb +43 -7
  326. data/spec/unit/module_tool/applications/installer_spec.rb +10 -1
  327. data/spec/unit/module_tool/applications/unpacker_spec.rb +2 -1
  328. data/spec/unit/module_tool/applications/upgrader_spec.rb +8 -0
  329. data/spec/unit/module_tool/tar/mini_spec.rb +3 -3
  330. data/spec/unit/network/http/api/indirected_routes_spec.rb +49 -58
  331. data/spec/unit/network/http/api/master/v3_spec.rb +7 -4
  332. data/spec/unit/network/rights_spec.rb +1 -1
  333. data/spec/unit/parameter_spec.rb +11 -0
  334. data/spec/unit/parser/compiler_spec.rb +19 -33
  335. data/spec/unit/{appmgmt_spec.rb → parser/environment_compiler_spec.rb} +12 -1
  336. data/spec/unit/parser/functions/create_resources_spec.rb +76 -4
  337. data/spec/unit/parser/functions/require_spec.rb +2 -2
  338. data/spec/unit/parser/resource_spec.rb +21 -11
  339. data/spec/unit/parser/scope_spec.rb +1 -5
  340. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +1 -1
  341. data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
  342. data/spec/unit/pops/loaders/loader_paths_spec.rb +1 -1
  343. data/spec/unit/pops/loaders/loaders_spec.rb +63 -5
  344. data/spec/unit/pops/loaders/module_loaders_spec.rb +2 -2
  345. data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
  346. data/spec/unit/pops/parser/lexer2_spec.rb +27 -3
  347. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +8 -0
  348. data/spec/unit/pops/parser/parse_calls_spec.rb +9 -0
  349. data/spec/unit/pops/puppet_stack_spec.rb +79 -0
  350. data/spec/unit/pops/resource/resource_type_impl_spec.rb +37 -0
  351. data/spec/unit/pops/serialization/packer_spec.rb +153 -0
  352. data/spec/unit/pops/serialization/rgen_spec.rb +88 -0
  353. data/spec/unit/pops/serialization/serialization_spec.rb +228 -0
  354. data/spec/unit/pops/types/p_object_type_spec.rb +44 -2
  355. data/spec/unit/pops/types/p_sem_ver_type_spec.rb +42 -0
  356. data/spec/unit/pops/types/p_sensitive_type_spec.rb +139 -0
  357. data/spec/unit/pops/types/p_type_set_type_spec.rb +424 -0
  358. data/spec/unit/pops/types/ruby_generator_spec.rb +497 -181
  359. data/spec/unit/pops/types/type_calculator_spec.rb +10 -4
  360. data/spec/unit/pops/types/type_formatter_spec.rb +1 -1
  361. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +2 -2
  362. data/spec/unit/pops/types/type_parser_spec.rb +1 -1
  363. data/spec/unit/pops/types/types_spec.rb +1 -1
  364. data/spec/unit/pops/validator/validator_spec.rb +18 -1
  365. data/spec/unit/property_spec.rb +48 -11
  366. data/spec/unit/provider/group/windows_adsi_spec.rb +11 -1
  367. data/spec/unit/provider/package/dnf_spec.rb +1 -99
  368. data/spec/unit/provider/package/pacman_spec.rb +4 -4
  369. data/spec/unit/provider/package/pip_spec.rb +14 -0
  370. data/spec/unit/provider/package/pkg_spec.rb +6 -0
  371. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -3
  372. data/spec/unit/provider/package/portage_spec.rb +64 -8
  373. data/spec/unit/provider/package/tdnf_spec.rb +18 -0
  374. data/spec/unit/provider/package/windows/package_spec.rb +4 -1
  375. data/spec/unit/provider/package/windows_spec.rb +8 -2
  376. data/spec/unit/provider/package/yum_spec.rb +6 -377
  377. data/spec/unit/provider/service/base_spec.rb +6 -0
  378. data/spec/unit/provider/service/debian_spec.rb +16 -7
  379. data/spec/unit/provider/service/gentoo_spec.rb +6 -0
  380. data/spec/unit/provider/service/init_spec.rb +7 -0
  381. data/spec/unit/provider/service/launchd_spec.rb +35 -4
  382. data/spec/unit/provider/service/openrc_spec.rb +6 -0
  383. data/spec/unit/provider/service/smf_spec.rb +31 -6
  384. data/spec/unit/provider/service/src_spec.rb +6 -0
  385. data/spec/unit/provider/service/systemd_spec.rb +70 -20
  386. data/spec/unit/provider/service/upstart_spec.rb +6 -0
  387. data/spec/unit/provider/user/aix_spec.rb +7 -0
  388. data/spec/unit/provider/user/directoryservice_spec.rb +30 -1
  389. data/spec/unit/provider/user/windows_adsi_spec.rb +19 -0
  390. data/spec/unit/resource/capability_finder_spec.rb +51 -3
  391. data/spec/unit/resource/catalog_spec.rb +5 -0
  392. data/spec/unit/resource/type_spec.rb +2 -2
  393. data/spec/unit/resource_spec.rb +19 -0
  394. data/spec/unit/settings_spec.rb +13 -0
  395. data/spec/unit/ssl/certificate_authority/interface_spec.rb +176 -10
  396. data/spec/unit/ssl/certificate_authority_spec.rb +63 -22
  397. data/spec/unit/ssl/host_spec.rb +1 -1
  398. data/spec/unit/ssl/oids_spec.rb +24 -21
  399. data/spec/unit/transaction/event_spec.rb +3 -1
  400. data/spec/unit/transaction/persistence_spec.rb +173 -0
  401. data/spec/unit/transaction/report_spec.rb +64 -1
  402. data/spec/unit/transaction/resource_harness_spec.rb +91 -0
  403. data/spec/unit/type/file/content_spec.rb +47 -15
  404. data/spec/unit/type/file_spec.rb +28 -0
  405. data/spec/unit/type/mount_spec.rb +5 -12
  406. data/spec/unit/type/yumrepo_spec.rb +1 -5
  407. data/spec/unit/type_spec.rb +32 -0
  408. data/spec/unit/util/command_line_spec.rb +11 -0
  409. data/spec/unit/util/execution_spec.rb +1 -1
  410. data/spec/unit/util/plist_spec.rb +16 -3
  411. data/spec/unit/util/storage_spec.rb +4 -1
  412. data/spec/unit/util/windows/adsi_spec.rb +23 -2
  413. data/spec/unit/util/windows/file_spec.rb +56 -1
  414. data/spec/unit/util/windows/sid_spec.rb +31 -7
  415. data/spec/unit/util/yaml_spec.rb +12 -0
  416. data/spec/unit/util_spec.rb +87 -20
  417. metadata +89 -34
  418. data/ext/puppetlisten/puppetlisten.rb +0 -77
  419. data/ext/puppetlisten/puppetrun.rb +0 -38
  420. data/lib/puppet/resource/type_collection_helper.rb +0 -7
  421. data/spec/unit/parser/functions/defined_spec.rb +0 -120
  422. data/spec/unit/resource/type_collection_helper_spec.rb +0 -24
@@ -4,11 +4,6 @@ module Types
4
4
  # Marker module for implementations that are mapped to Object types
5
5
  # @api public
6
6
  module PuppetObject
7
- # Returns all classes that includes this module
8
- def self.descendants
9
- ObjectSpace.each_object(Class).select { |klass| klass < self }
10
- end
11
-
12
7
  # Returns the Puppet Type for this instance. The implementing class must
13
8
  # add the {#_ptype} as a class method.
14
9
  #
@@ -27,9 +27,16 @@ class RubyGenerator < TypeFormatter
27
27
  cls.define_singleton_method(:_ptype) { return key }
28
28
  hash[key] = cls
29
29
  end
30
+ raise ArgumentError, "Expected a Puppet Type, got '#{obj.class.name}'" unless obj.is_a?(PAnyType)
30
31
  @dynamic_classes[obj]
31
32
  end
32
33
 
34
+ def module_definition_from_typeset(typeset)
35
+ module_definition(
36
+ typeset.types.values,
37
+ "# Generated by #{self.class.name} from TypeSet #{typeset.name} on #{Date.new}\n")
38
+ end
39
+
33
40
  def module_definition(types, comment)
34
41
  object_types, aliased_types = types.partition { |type| type.is_a?(PObjectType) }
35
42
  impl_names = implementation_names(object_types)
@@ -74,10 +81,10 @@ class RubyGenerator < TypeFormatter
74
81
 
75
82
  # Emit registration of contained types
76
83
  unless class_names.empty?
77
- bld << "Puppet::Pops::Pcore.register_implementations(\n"
84
+ bld << "Puppet::Pops::Pcore.register_implementations([\n"
78
85
  class_names.each { |class_name| bld << ' ' << class_name << ",\n" }
79
86
  bld.chomp!(",\n")
80
- bld << ")\n\n"
87
+ bld << "])\n\n"
81
88
  end
82
89
  bld.chomp!("\n")
83
90
 
@@ -643,6 +643,11 @@ class TypeCalculator
643
643
  end
644
644
  end
645
645
 
646
+ # @api private
647
+ def infer_Sensitive(o)
648
+ PSensitiveType.new(infer(o.unwrap))
649
+ end
650
+
646
651
  # @api private
647
652
  def infer_TrueClass(o)
648
653
  PBooleanType::DEFAULT
@@ -726,7 +731,7 @@ class TypeCalculator
726
731
 
727
732
  # @api private
728
733
  def infer_set_Version(o)
729
- PSemVerType.new(Semantic::VersionRange.new(o, o))
734
+ PSemVerType.new([Semantic::VersionRange.new(o, o)])
730
735
  end
731
736
 
732
737
  def unwrap_single_variant(possible_variant)
@@ -40,6 +40,13 @@ module TypeFactory
40
40
  PFloatType::DEFAULT
41
41
  end
42
42
 
43
+ # Produces the Sensitive type
44
+ # @api public
45
+ #
46
+ def self.sensitive(type = nil)
47
+ PSensitiveType.new(type)
48
+ end
49
+
43
50
  # Produces the Numeric type
44
51
  # @api public
45
52
  #
@@ -157,6 +164,10 @@ module TypeFactory
157
164
  hash.nil? || hash.empty? ? PObjectType::DEFAULT : PObjectType.new(hash)
158
165
  end
159
166
 
167
+ def self.type_set(hash = nil)
168
+ hash.nil? || hash.empty? ? PTypeSetType::DEFAULT : PTypeSetType.new(hash)
169
+ end
170
+
160
171
  def self.tuple(types = [], size_type = nil)
161
172
  PTupleType.new(types.map {|elem| type_of(elem) }, size_type)
162
173
  end
@@ -181,13 +192,7 @@ module TypeFactory
181
192
  # @api public
182
193
  #
183
194
  def self.regexp(pattern = nil)
184
- if pattern
185
- t = PRegexpType.new(pattern.is_a?(Regexp) ? pattern.inspect[1..-2] : pattern)
186
- t.regexp unless pattern.nil? # compile pattern to catch errors
187
- t
188
- else
189
- PRegexpType::DEFAULT
190
- end
195
+ pattern ? PRegexpType.new(pattern) : PRegexpType::DEFAULT
191
196
  end
192
197
 
193
198
  def self.pattern(*regular_expressions)
@@ -199,10 +204,7 @@ module TypeFactory
199
204
  re_t
200
205
 
201
206
  when Regexp
202
- # Regep.to_s includes options user did not enter and does not escape source
203
- # to work either as a string or as a // regexp. The inspect method does a better
204
- # job, but includes the //
205
- PRegexpType.new(re.inspect[1..-2])
207
+ PRegexpType.new(re)
206
208
 
207
209
  when PRegexpType
208
210
  re
@@ -311,7 +313,7 @@ module TypeFactory
311
313
 
312
314
  # Produces an instance of the SemVer type
313
315
  def self.sem_ver(*ranges)
314
- ranges.empty? ? PSemVerType::DEFAULT : PSemVerType::new(*ranges)
316
+ ranges.empty? ? PSemVerType::DEFAULT : PSemVerType::new(ranges)
315
317
  end
316
318
 
317
319
  # Produces a PResourceType with a String type_name A PResourceType with a nil
@@ -335,44 +335,47 @@ class TypeFormatter
335
335
  end
336
336
 
337
337
  # @api private
338
- def string_PObjectType(t)
339
- if @expanded
340
- begin
341
- @expanded = false
342
- append_array('Object') do
343
- append_hash(t.i12n_hash.each, proc { |k| @bld << symbolic_key(k) }) do |k,v|
344
- case k
345
- when PObjectType::KEY_ATTRIBUTES, PObjectType::KEY_FUNCTIONS
346
- # Types might need to be output as type references
347
- append_hash(v) do |_, fv|
348
- if fv.is_a?(Hash)
349
- append_hash(fv, proc { |fak| @bld << symbolic_key(fak) }) do |fak,fav|
350
- case fak
351
- when PObjectType::KEY_KIND
352
- @bld << fav
353
- else
354
- append_string(fav)
355
- end
356
- end
357
- else
358
- append_string(fv)
359
- end
338
+ def string_PTypeSetType(t)
339
+ append_array('TypeSet') do
340
+ append_hash(t.i12n_hash.each, proc { |k| @bld << symbolic_key(k) }) do |k,v|
341
+ case k
342
+ when KEY_TYPES
343
+ old_ts = @type_set
344
+ @type_set = t
345
+ begin
346
+ append_hash(v, proc { |tk| @bld << symbolic_key(tk) }) do |tk, tv|
347
+ if tv.is_a?(Hash)
348
+ append_object_hash(tv)
349
+ else
350
+ append_string(tv)
360
351
  end
361
- when PObjectType::KEY_EQUALITY
362
- append_array('') { append_strings(v) } if v.is_a?(Array)
363
- else
364
- append_string(v)
365
352
  end
353
+ rescue
354
+ @type_set = old_ts
366
355
  end
356
+ when KEY_REFERENCES
357
+ append_hash(v, proc { |tk| @bld << symbolic_key(tk) })
358
+ else
359
+ append_string(v)
367
360
  end
368
- ensure
369
- @expanded = true
370
361
  end
362
+ end
363
+ end
364
+
365
+ # @api private
366
+ def string_PObjectType(t)
367
+ if @expanded
368
+ append_object_hash(t.i12n_hash(@type_set.nil? || !@type_set.defines_type?(t)))
371
369
  else
372
- @bld << t.label
370
+ @bld << (@type_set ? @type_set.name_for(t) : t.label)
373
371
  end
374
372
  end
375
373
 
374
+ # @api private
375
+ def string_PSensitiveType(t)
376
+ append_array('Sensitive') { append_string(t.type) }
377
+ end
378
+
376
379
  # @api private
377
380
  def string_POptionalType(t)
378
381
  optional_type = t.optional_type
@@ -392,10 +395,18 @@ class TypeFormatter
392
395
  @guard ||= RecursionGuard.new
393
396
  expand = (@guard.add_this(t) & RecursionGuard::SELF_RECURSION_IN_THIS) == 0
394
397
  end
395
- @bld << t.name
396
- if expand
397
- @bld << ' = '
398
- append_string(t.resolved_type)
398
+ if @type_set.nil?
399
+ @bld << t.name
400
+ if expand
401
+ @bld << ' = '
402
+ append_string(t.resolved_type)
403
+ end
404
+ else
405
+ if expand && @type_set.defines_type?(t)
406
+ append_string(t.resolved_type)
407
+ else
408
+ @bld << @type_set.name_for(t)
409
+ end
399
410
  end
400
411
  end
401
412
 
@@ -489,6 +500,40 @@ class TypeFormatter
489
500
  t.nil? || t.unbounded? ? EMPTY_ARRAY : [t.from.nil? ? 'default' : t.from.to_s , t.to.nil? ? 'default' : t.to.to_s ]
490
501
  end
491
502
 
503
+ def append_object_hash(hash)
504
+ begin
505
+ @expanded = false
506
+ append_array('Object') do
507
+ append_hash(hash, proc { |k| @bld << symbolic_key(k) }) do |k,v|
508
+ case k
509
+ when KEY_ATTRIBUTES, KEY_FUNCTIONS
510
+ # Types might need to be output as type references
511
+ append_hash(v) do |_, fv|
512
+ if fv.is_a?(Hash)
513
+ append_hash(fv, proc { |fak| @bld << symbolic_key(fak) }) do |fak,fav|
514
+ case fak
515
+ when KEY_KIND
516
+ @bld << fav
517
+ else
518
+ append_string(fav)
519
+ end
520
+ end
521
+ else
522
+ append_string(fv)
523
+ end
524
+ end
525
+ when KEY_EQUALITY
526
+ append_array('') { append_strings(v) } if v.is_a?(Array)
527
+ else
528
+ append_string(v)
529
+ end
530
+ end
531
+ end
532
+ ensure
533
+ @expanded = true
534
+ end
535
+ end
536
+
492
537
  def append_elements(array, to_be_continued = false)
493
538
  case array.size
494
539
  when 0
@@ -1,7 +1,5 @@
1
1
  module Puppet::Pops
2
2
  module Types
3
- EMPTY_ARRAY = [].freeze
4
-
5
3
  class TypePathElement
6
4
  attr_reader :key
7
5
 
@@ -8,6 +8,10 @@
8
8
  module Puppet::Pops
9
9
  module Types
10
10
  class TypeParser
11
+ def self.singleton
12
+ @singleton ||= TypeParser.new
13
+ end
14
+
11
15
  # @api public
12
16
  def initialize
13
17
  @parser = Parser::Parser.new
@@ -33,7 +37,11 @@ class TypeParser
33
37
  interpret(model.current.body, context)
34
38
  end
35
39
 
36
- # @api private
40
+ # @param ast [Puppet::Pops::Model::PopsObject] the ast to interpret
41
+ # @param context [Puppet::Parser::Scope,Loader::Loader, nil] scope or loader to use when loading type aliases
42
+ # @return [PAnyType] a specialization of the PAnyType representing the type.
43
+ #
44
+ # @api public
37
45
  def interpret(ast, context)
38
46
  result = @type_transformer.visit_this_1(self, ast, context)
39
47
  raise_invalid_type_specification_error(ast) unless result.is_a?(PAnyType)
@@ -132,6 +140,7 @@ class TypeParser
132
140
  'iterable' => TypeFactory.iterable,
133
141
  'iterator' => TypeFactory.iterator,
134
142
  'string' => TypeFactory.string,
143
+ 'sensitive' => TypeFactory.sensitive,
135
144
  'enum' => TypeFactory.enum,
136
145
  'boolean' => TypeFactory.boolean,
137
146
  'pattern' => TypeFactory.pattern,
@@ -157,6 +166,7 @@ class TypeParser
157
166
  'object' => TypeFactory.object,
158
167
  'typealias' => TypeFactory.type_alias,
159
168
  'typereference' => TypeFactory.type_reference,
169
+ 'typeset' => TypeFactory.type_set,
160
170
  # A generic callable as opposed to one that does not accept arguments
161
171
  'callable' => TypeFactory.all_callables,
162
172
  'semver' => TypeFactory.sem_ver,
@@ -372,6 +382,10 @@ class TypeParser
372
382
  raise_invalid_parameters_error('Object', 1, parameters.size) unless parameters.size == 1
373
383
  TypeFactory.object(parameters[0])
374
384
 
385
+ when 'typeset'
386
+ raise_invalid_parameters_error('Object', 1, parameters.size) unless parameters.size == 1
387
+ TypeFactory.type_set(parameters[0])
388
+
375
389
  when 'iterable'
376
390
  if parameters.size != 1
377
391
  raise_invalid_parameters_error('Iterable', 1, parameters.size)
@@ -419,6 +433,17 @@ class TypeParser
419
433
  end
420
434
  TypeFactory.string(size_type)
421
435
 
436
+ when 'sensitive'
437
+ if parameters.size == 0
438
+ TypeFactory.sensitive
439
+ elsif parameters.size == 1
440
+ param = parameters[0]
441
+ assert_type(ast, param)
442
+ TypeFactory.sensitive(param)
443
+ else
444
+ raise_invalid_parameters_error('Sensitive', '0 to 1', parameters.size)
445
+ end
446
+
422
447
  when 'optional'
423
448
  if parameters.size != 1
424
449
  raise_invalid_parameters_error('Optional', 1, parameters.size)
@@ -468,7 +493,7 @@ class TypeParser
468
493
  if type.nil?
469
494
  TypeFactory.type_reference(original_text_of(qref.eContainer))
470
495
  elsif type.is_a?(PResourceType)
471
- raise_invalid_parameters_error(type_name, 1, parameters.size) unless parameters.size == 1
496
+ raise_invalid_parameters_error(qref.cased_value, 1, parameters.size) unless parameters.size == 1
472
497
  TypeFactory.resource(type.type_name, parameters[0])
473
498
  else
474
499
  # Must be a type alias. They can't use parameters (yet)
@@ -0,0 +1,59 @@
1
+ module Puppet::Pops
2
+ module Types
3
+ class TypeSetReference
4
+ include Annotatable
5
+
6
+ attr_reader :name_authority
7
+ attr_reader :name
8
+ attr_reader :version_range
9
+ attr_reader :type_set
10
+
11
+ def initialize(owner, i12n_hash)
12
+ @owner = owner
13
+ @name_authority = (i12n_hash[KEY_NAME_AUTHORITY] || owner.name_authority).freeze
14
+ @name = i12n_hash[KEY_NAME].freeze
15
+ @version_range = PSemVerRangeType.convert(i12n_hash[KEY_VERSION_RANGE])
16
+ init_annotatable(i12n_hash)
17
+ end
18
+
19
+ def accept(visitor, guard)
20
+ annotatable_accept(visitor, guard)
21
+ end
22
+
23
+ def eql?(o)
24
+ self.class == o.class && @name_authority.eql?(o.name_authority) && @name.eql?(o.name) && @version_range.eql?(o.version_range)
25
+ end
26
+
27
+ def hash
28
+ [@name_authority, @name, @version_range].hash
29
+ end
30
+
31
+ def i12n_hash
32
+ result = super
33
+ result[KEY_NAME_AUTHORITY] = @name_authority unless @name_authority == @owner.name_authority
34
+ result[KEY_NAME] = @name
35
+ result[KEY_VERSION_RANGE] = @version_range.to_s
36
+ result
37
+ end
38
+
39
+ def resolve(type_parser, loader)
40
+ typed_name = Loader::TypedName.new(:type, @name.downcase, @name_authority)
41
+ loaded_entry = loader.load_typed(typed_name)
42
+ type_set = loaded_entry.nil? ? nil : loaded_entry.value
43
+
44
+ raise ArgumentError, "#{self} cannot be resolved" if type_set.nil?
45
+ raise ArgumentError, "#{self} resolves to a #{type_set.name}" unless type_set.is_a?(PTypeSetType)
46
+
47
+ @type_set = type_set.resolve(type_parser, loader)
48
+ unless @version_range.include?(@type_set.version)
49
+ raise ArgumentError, "#{self} resolves to an incompatible version. Expected #{@version_range}, got #{type_set.version}"
50
+ end
51
+ nil
52
+ end
53
+
54
+ def to_s
55
+ "#{@owner.label} reference to TypeSet named '#{@name}'"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -11,11 +11,25 @@ require_relative 'type_factory'
11
11
  require_relative 'type_parser'
12
12
  require_relative 'class_loader'
13
13
  require_relative 'type_mismatch_describer'
14
+ require_relative 'puppet_object'
14
15
 
15
16
  module Puppet::Pops
16
17
  module Types
17
18
 
18
- EMPTY_HASH = {}.freeze
19
+ # The EMPTY_xxx declarations is for backward compatibility. They should not be explicitly referenced
20
+
21
+ # @api private
22
+ # @deprecated
23
+ EMPTY_HASH = Puppet::Pops::EMPTY_HASH
24
+
25
+ # @api private
26
+ # @deprecated
27
+ EMPTY_ARRAY = Puppet::Pops::EMPTY_ARRAY
28
+
29
+ # @api private
30
+ # @deprecated
31
+ EMPTY_STRING = Puppet::Pops::EMPTY_STRING
32
+
19
33
  # The Types model is a model of Puppet Language types.
20
34
  #
21
35
  # The exact relationship between types is not visible in this model wrt. the PDataType which is an abstraction
@@ -32,14 +46,40 @@ EMPTY_HASH = {}.freeze
32
46
  #
33
47
  # TODO: See PUP-2978 for possible performance optimization
34
48
  class TypedModelObject < Object
49
+ include PuppetObject
35
50
  include Visitable
36
51
  include Adaptable
52
+
53
+ def self._ptype
54
+ @type
55
+ end
56
+
57
+ def self.create_ptype(loader, ir, parent_name, attributes_hash = EMPTY_HASH)
58
+ @type = Pcore::create_object_type(loader, ir, self, "Pcore::#{simple_name}Type", "Pcore::#{parent_name}", attributes_hash)
59
+ end
60
+
61
+ def self.register_ptypes(loader, ir)
62
+ types = []
63
+ Types.constants.each do |c|
64
+ cls = Types.const_get(c)
65
+ next unless cls.is_a?(Class) && cls < self
66
+ type = cls.register_ptype(loader, ir)
67
+ types << type unless type.nil?
68
+ end
69
+ tp = TypeParser.singleton
70
+ types.each { |type| type.resolve(tp, loader) }
71
+ end
37
72
  end
38
73
 
39
74
  # Base type for all types
40
75
  # @api public
41
76
  #
42
77
  class PAnyType < TypedModelObject
78
+
79
+ def self.register_ptype(loader, ir)
80
+ @type = Pcore::create_object_type(loader, ir, self, 'Pcore::AnyType', 'Any', EMPTY_HASH)
81
+ end
82
+
43
83
  # Accept a visitor that will be sent the message `visit`, once with `self` as the
44
84
  # argument. The visitor will then visit all types that this type contains.
45
85
  #
@@ -222,12 +262,19 @@ class PAnyType < TypedModelObject
222
262
  eql?(o)
223
263
  end
224
264
 
265
+ def simple_name
266
+ self.class.simple_name
267
+ end
268
+
225
269
  # Strips the class name from all module prefixes, the leading 'P' and the ending 'Type'. I.e.
226
270
  # an instance of PVariantType will return 'Variant'
227
271
  # @return [String] the simple name of this type
228
- def simple_name
229
- n = self.class.name
230
- n[n.rindex('::')+3..n.size-5]
272
+ def self.simple_name
273
+ if @simple_name.nil?
274
+ n = name
275
+ @simple_name = n[n.rindex('::')+3..n.size-5]
276
+ end
277
+ @simple_name
231
278
  end
232
279
 
233
280
  def to_alias_expanded_s
@@ -322,6 +369,10 @@ end
322
369
  # @abstract Encapsulates common behavior for a type that contains one type
323
370
  # @api public
324
371
  class PTypeWithContainedType < PAnyType
372
+ def self.register_ptype(loader, ir)
373
+ # Abstract type. It doesn't register anything
374
+ end
375
+
325
376
  attr_reader :type
326
377
 
327
378
  def initialize(type)
@@ -358,12 +409,28 @@ class PTypeWithContainedType < PAnyType
358
409
  def eql?(o)
359
410
  self.class == o.class && @type == o.type
360
411
  end
412
+
413
+ def resolve(type_parser, loader)
414
+ rtype = @type
415
+ rtype = rtype.resolve(type_parser, loader) unless rtype.nil?
416
+ rtype.equal?(@type) ? self : self.class.new(rtype)
417
+ end
361
418
  end
362
419
 
363
420
  # The type of types.
364
421
  # @api public
365
422
  #
366
423
  class PType < PTypeWithContainedType
424
+
425
+ def self.register_ptype(loader, ir)
426
+ create_ptype(loader, ir, 'AnyType',
427
+ 'type' => {
428
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
429
+ KEY_VALUE => nil
430
+ }
431
+ )
432
+ end
433
+
367
434
  def instance?(o, guard = nil)
368
435
  if o.is_a?(PAnyType)
369
436
  type.nil? || type.assignable?(o, guard)
@@ -403,7 +470,7 @@ class PType < PTypeWithContainedType
403
470
  self.class == o.class && @type == o.type
404
471
  end
405
472
 
406
- def simple_name
473
+ def self.simple_name
407
474
  # since this the class is inconsistently named PType and not PTypeType
408
475
  'Type'
409
476
  end
@@ -422,6 +489,15 @@ class PType < PTypeWithContainedType
422
489
  end
423
490
 
424
491
  class PNotUndefType < PTypeWithContainedType
492
+ def self.register_ptype(loader, ir)
493
+ create_ptype(loader, ir, 'AnyType',
494
+ 'type' => {
495
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
496
+ KEY_VALUE => nil
497
+ }
498
+ )
499
+ end
500
+
425
501
  def initialize(type = nil)
426
502
  super(type.class == PAnyType ? nil : type)
427
503
  end
@@ -469,6 +545,10 @@ end
469
545
  # @api public
470
546
  #
471
547
  class PUndefType < PAnyType
548
+ def self.register_ptype(loader, ir)
549
+ create_ptype(loader, ir, 'AnyType')
550
+ end
551
+
472
552
  def instance?(o, guard = nil)
473
553
  o.nil? || o == :undef
474
554
  end
@@ -492,6 +572,10 @@ end
492
572
  # @api private
493
573
  #
494
574
  class PUnitType < PAnyType
575
+ def self.register_ptype(loader, ir)
576
+ create_ptype(loader, ir, 'AnyType')
577
+ end
578
+
495
579
  def instance?(o, guard = nil)
496
580
  true
497
581
  end
@@ -521,6 +605,10 @@ end
521
605
  # @api public
522
606
  #
523
607
  class PDefaultType < PAnyType
608
+ def self.register_ptype(loader, ir)
609
+ create_ptype(loader, ir, 'AnyType')
610
+ end
611
+
524
612
  def instance?(o, guard = nil)
525
613
  o == :default
526
614
  end
@@ -539,6 +627,10 @@ end
539
627
  # @api public
540
628
  #
541
629
  class PDataType < PAnyType
630
+ def self.register_ptype(loader, ir)
631
+ create_ptype(loader, ir, 'AnyType')
632
+ end
633
+
542
634
  def eql?(o)
543
635
  self.class == o.class || o == PVariantType::DATA
544
636
  end
@@ -570,6 +662,9 @@ end
570
662
  # @api public
571
663
  #
572
664
  class PScalarType < PAnyType
665
+ def self.register_ptype(loader, ir)
666
+ create_ptype(loader, ir, 'AnyType')
667
+ end
573
668
 
574
669
  def instance?(o, guard = nil)
575
670
  assignable?(TypeCalculator.infer(o), guard)
@@ -589,6 +684,10 @@ end
589
684
  # @api public
590
685
  #
591
686
  class PEnumType < PScalarType
687
+ def self.register_ptype(loader, ir)
688
+ create_ptype(loader, ir, 'ScalarType', 'values' => PArrayType.new(PStringType::NON_EMPTY))
689
+ end
690
+
592
691
  attr_reader :values
593
692
 
594
693
  def initialize(values)
@@ -645,6 +744,13 @@ end
645
744
  # @api public
646
745
  #
647
746
  class PNumericType < PScalarType
747
+ def self.register_ptype(loader, ir)
748
+ create_ptype(loader, ir, 'ScalarType',
749
+ 'from' => { KEY_TYPE => PNumericType::DEFAULT, KEY_VALUE => :default },
750
+ 'to' => { KEY_TYPE => PNumericType::DEFAULT, KEY_VALUE => :default }
751
+ )
752
+ end
753
+
648
754
  def initialize(from, to = Float::INFINITY)
649
755
  from = -Float::INFINITY if from.nil? || from == :default
650
756
  to = Float::INFINITY if to.nil? || to == :default
@@ -767,6 +873,10 @@ end
767
873
  # @api public
768
874
  #
769
875
  class PIntegerType < PNumericType
876
+ def self.register_ptype(loader, ir)
877
+ create_ptype(loader, ir, 'NumericType')
878
+ end
879
+
770
880
  # Will respond `true` for any range that is bounded at both ends.
771
881
  #
772
882
  # @return [Boolean] `true` if the type describes a finite range.
@@ -919,6 +1029,10 @@ end
919
1029
  # @api public
920
1030
  #
921
1031
  class PFloatType < PNumericType
1032
+ def self.register_ptype(loader, ir)
1033
+ create_ptype(loader, ir, 'NumericType')
1034
+ end
1035
+
922
1036
  def generalize
923
1037
  DEFAULT
924
1038
  end
@@ -1012,6 +1126,15 @@ end
1012
1126
  # @api public
1013
1127
  #
1014
1128
  class PCollectionType < PAnyType
1129
+ def self.register_ptype(loader, ir)
1130
+ create_ptype(loader, ir, 'AnyType',
1131
+ 'element_type' => {
1132
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
1133
+ KEY_VALUE => nil
1134
+ }
1135
+ )
1136
+ end
1137
+
1015
1138
  attr_reader :element_type, :size_type
1016
1139
 
1017
1140
  def initialize(element_type, size_type = nil)
@@ -1051,6 +1174,12 @@ class PCollectionType < PAnyType
1051
1174
  assignable?(TypeCalculator.infer(o), guard)
1052
1175
  end
1053
1176
 
1177
+ def resolve(type_parser, loader)
1178
+ relement_type = @element_type
1179
+ relement_type = relement_type.resolve(type_parser, loader) unless relement_type.nil?
1180
+ relement_type.equal?(@element_type) ? self : self.class.new(relement_type, @size_type)
1181
+ end
1182
+
1054
1183
  # Returns an array with from (min) size to (max) size
1055
1184
  def size_range
1056
1185
  (@size_type || DEFAULT_SIZE).range
@@ -1080,6 +1209,7 @@ class PCollectionType < PAnyType
1080
1209
 
1081
1210
  DEFAULT_SIZE = PIntegerType.new(0)
1082
1211
  ZERO_SIZE = PIntegerType.new(0, 0)
1212
+ NOT_EMPTY_SIZE = PIntegerType.new(1)
1083
1213
  DEFAULT = PCollectionType.new(nil)
1084
1214
 
1085
1215
  protected
@@ -1109,6 +1239,15 @@ class PCollectionType < PAnyType
1109
1239
  end
1110
1240
 
1111
1241
  class PIterableType < PTypeWithContainedType
1242
+ def self.register_ptype(loader, ir)
1243
+ create_ptype(loader, ir, 'AnyType',
1244
+ 'element_type' => {
1245
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
1246
+ KEY_VALUE => nil
1247
+ }
1248
+ )
1249
+ end
1250
+
1112
1251
  def element_type
1113
1252
  @type
1114
1253
  end
@@ -1158,6 +1297,15 @@ end
1158
1297
  # @api public
1159
1298
  #
1160
1299
  class PIteratorType < PTypeWithContainedType
1300
+ def self.register_ptype(loader, ir)
1301
+ create_ptype(loader, ir, 'AnyType',
1302
+ 'element_type' => {
1303
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
1304
+ KEY_VALUE => nil
1305
+ }
1306
+ )
1307
+ end
1308
+
1161
1309
  def element_type
1162
1310
  @type
1163
1311
  end
@@ -1187,6 +1335,19 @@ end
1187
1335
  # @api public
1188
1336
  #
1189
1337
  class PStringType < PScalarType
1338
+ def self.register_ptype(loader, ir)
1339
+ create_ptype(loader, ir, 'ScalarType',
1340
+ 'size_type' => {
1341
+ KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
1342
+ KEY_VALUE => nil
1343
+ },
1344
+ 'values' => {
1345
+ KEY_TYPE => PArrayType.new(PStringType::DEFAULT),
1346
+ KEY_VALUE => EMPTY_ARRAY
1347
+ }
1348
+ )
1349
+ end
1350
+
1190
1351
  attr_reader :size_type, :values
1191
1352
 
1192
1353
  def initialize(size_type, values = EMPTY_ARRAY)
@@ -1255,7 +1416,7 @@ class PStringType < PScalarType
1255
1416
  end
1256
1417
 
1257
1418
  DEFAULT = PStringType.new(nil)
1258
- NON_EMPTY = PStringType.new(PIntegerType.new(1))
1419
+ NON_EMPTY = PStringType.new(PCollectionType::NOT_EMPTY_SIZE)
1259
1420
 
1260
1421
  # Iterates over each character of the string
1261
1422
  ITERABLE_TYPE = PIterableType.new(PStringType.new(PIntegerType.new(1,1)))
@@ -1309,12 +1470,19 @@ end
1309
1470
  # @api public
1310
1471
  #
1311
1472
  class PRegexpType < PScalarType
1473
+ def self.register_ptype(loader, ir)
1474
+ create_ptype(loader, ir, 'ScalarType',
1475
+ 'pattern' => {
1476
+ KEY_TYPE => PVariantType.new([PUndefType::DEFAULT, PStringType::DEFAULT, PRegexpType::DEFAULT]),
1477
+ KEY_VALUE => nil
1478
+ })
1479
+ end
1312
1480
  attr_reader :pattern
1313
1481
 
1314
1482
  def initialize(pattern)
1315
1483
  if pattern.is_a?(Regexp)
1316
1484
  @regexp = pattern
1317
- @pattern = pattern.source
1485
+ @pattern = pattern.options == 0 ? pattern.source : pattern.to_s
1318
1486
  else
1319
1487
  @pattern = pattern
1320
1488
  end
@@ -1349,6 +1517,10 @@ end
1349
1517
  # @api public
1350
1518
  #
1351
1519
  class PPatternType < PScalarType
1520
+ def self.register_ptype(loader, ir)
1521
+ create_ptype(loader, ir, 'ScalarType', 'patterns' => PArrayType.new(PRegexpType::DEFAULT))
1522
+ end
1523
+
1352
1524
  attr_reader :patterns
1353
1525
 
1354
1526
  def initialize(patterns)
@@ -1399,6 +1571,9 @@ end
1399
1571
  # @api public
1400
1572
  #
1401
1573
  class PBooleanType < PScalarType
1574
+ def self.register_ptype(loader, ir)
1575
+ create_ptype(loader, ir, 'ScalarType')
1576
+ end
1402
1577
 
1403
1578
  def instance?(o, guard = nil)
1404
1579
  o == true || o == false
@@ -1448,6 +1623,12 @@ end
1448
1623
  # @api public
1449
1624
  #
1450
1625
  class PStructElement < TypedModelObject
1626
+ def self.register_ptype(loader, ir)
1627
+ @type = Pcore::create_object_type(loader, ir, self, 'Pcore::StructElement'.freeze, nil,
1628
+ 'key_type' => PType::DEFAULT,
1629
+ 'value_type' => PType::DEFAULT)
1630
+ end
1631
+
1451
1632
  attr_accessor :key_type, :value_type
1452
1633
 
1453
1634
  def accept(visitor, guard)
@@ -1480,6 +1661,14 @@ class PStructElement < TypedModelObject
1480
1661
  @value_type.equal?(nv_type) ? self : PStructElement.new(@key_type, nv_type)
1481
1662
  end
1482
1663
 
1664
+ def resolve(type_parser, loader)
1665
+ rkey_type = @key_type
1666
+ rkey_type = rkey_type.resolve(type_parser, loader) unless rkey_type.nil?
1667
+ rvalue_type = @value_type
1668
+ rvalue_type = rvalue_type.resolve(type_parser, loader) unless rvalue_type.nil?
1669
+ rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type)
1670
+ end
1671
+
1483
1672
  def <=>(o)
1484
1673
  self.name <=> o.name
1485
1674
  end
@@ -1498,8 +1687,12 @@ end
1498
1687
  class PStructType < PAnyType
1499
1688
  include Enumerable
1500
1689
 
1690
+ def self.register_ptype(loader, ir)
1691
+ create_ptype(loader, ir, 'AnyType', 'elements' => PArrayType.new(PTypeReferenceType.new('Pcore::StructElement')))
1692
+ end
1693
+
1501
1694
  def initialize(elements)
1502
- @elements = elements.sort.freeze
1695
+ @elements = elements.freeze
1503
1696
  end
1504
1697
 
1505
1698
  def accept(visitor, guard)
@@ -1556,6 +1749,16 @@ class PStructType < PAnyType
1556
1749
  end
1557
1750
  end
1558
1751
 
1752
+ def resolve(type_parser, loader)
1753
+ changed = false
1754
+ relements = @elements.map do |elem|
1755
+ relem = elem.resolve(type_parser, loader)
1756
+ changed ||= !relem.equal?(elem)
1757
+ relem
1758
+ end
1759
+ changed ? self.class.new(relements) : self
1760
+ end
1761
+
1559
1762
  def eql?(o)
1560
1763
  self.class == o.class && @elements == o.elements
1561
1764
  end
@@ -1639,6 +1842,16 @@ end
1639
1842
  class PTupleType < PAnyType
1640
1843
  include Enumerable
1641
1844
 
1845
+ def self.register_ptype(loader, ir)
1846
+ create_ptype(loader, ir, 'AnyType',
1847
+ 'types' => PArrayType.new(PType::DEFAULT),
1848
+ 'size_type' => {
1849
+ KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
1850
+ KEY_VALUE => nil
1851
+ }
1852
+ )
1853
+ end
1854
+
1642
1855
  # If set, describes min and max required of the given types - if max > size of
1643
1856
  # types, the last type entry repeats
1644
1857
  #
@@ -1716,6 +1929,16 @@ class PTupleType < PAnyType
1716
1929
  end
1717
1930
  end
1718
1931
 
1932
+ def resolve(type_parser, loader)
1933
+ changed = false
1934
+ rtypes = @types.map do |type|
1935
+ rtype = type.resolve(type_parser, loader)
1936
+ changed ||= !rtype.equal?(type)
1937
+ rtype
1938
+ end
1939
+ changed ? self.class.new(rtypes, @size_type) : self
1940
+ end
1941
+
1719
1942
  def instance?(o, guard = nil)
1720
1943
  return false unless o.is_a?(Array)
1721
1944
  # compute the tuple's min/max size, and check if that size matches
@@ -1816,6 +2039,19 @@ end
1816
2039
  # @api public
1817
2040
  #
1818
2041
  class PCallableType < PAnyType
2042
+ def self.register_ptype(loader, ir)
2043
+ create_ptype(loader, ir, 'AnyType',
2044
+ 'param_types' => {
2045
+ KEY_TYPE => POptionalType.new(PTupleType::DEFAULT),
2046
+ KEY_VALUE => nil
2047
+ },
2048
+ 'block_type' => {
2049
+ KEY_TYPE => POptionalType.new(PCallableType::DEFAULT),
2050
+ KEY_VALUE => nil
2051
+ }
2052
+ )
2053
+ end
2054
+
1819
2055
  # Types of parameters as a Tuple with required/optional count, or an Integer with min (required), max count
1820
2056
  # @return [PTupleType] the tuple representing the parameter types
1821
2057
  attr_reader :param_types
@@ -1905,6 +2141,14 @@ class PCallableType < PAnyType
1905
2141
  self.class == o.class && @param_types == o.param_types && @block_type == o.block_type
1906
2142
  end
1907
2143
 
2144
+ def resolve(type_parser, loader)
2145
+ rparam_types = @param_types
2146
+ rparam_types = rparam_types.resolve(type_parser, loader) unless rparam_types.nil?
2147
+ rblock_type = @block_type
2148
+ rblock_type = rblock_type.resolve(type_parser, loader) unless rblock_type.nil?
2149
+ rparam_types.equal?(@param_types) && rblock_type.equal?(@block_type) ? self : self.class.new(rparam_types, rblock_type)
2150
+ end
2151
+
1908
2152
  DEFAULT = PCallableType.new(nil)
1909
2153
 
1910
2154
  protected
@@ -1932,6 +2176,15 @@ end
1932
2176
  #
1933
2177
  class PArrayType < PCollectionType
1934
2178
 
2179
+ def self.register_ptype(loader, ir)
2180
+ create_ptype(loader, ir, 'CollectionType',
2181
+ 'size_type' => {
2182
+ KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
2183
+ KEY_VALUE => nil
2184
+ }
2185
+ )
2186
+ end
2187
+
1935
2188
  # @api private
1936
2189
  def callable_args?(callable, guard = nil)
1937
2190
  param_t = callable.param_types
@@ -2036,7 +2289,27 @@ end
2036
2289
  # @api public
2037
2290
  #
2038
2291
  class PHashType < PCollectionType
2292
+
2293
+ def self.register_ptype(loader, ir)
2294
+ create_ptype(loader, ir, 'CollectionType',
2295
+ 'key_type' => {
2296
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
2297
+ KEY_VALUE => nil
2298
+ },
2299
+ 'element_type' => {
2300
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
2301
+ KEY_VALUE => nil,
2302
+ KEY_OVERRIDE => true
2303
+ },
2304
+ 'size_type' => {
2305
+ KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
2306
+ KEY_VALUE => nil
2307
+ }
2308
+ )
2309
+ end
2310
+
2039
2311
  attr_accessor :key_type
2312
+ alias value_type element_type
2040
2313
 
2041
2314
  def initialize(key_type, value_type, size_type = nil)
2042
2315
  super(value_type, size_type)
@@ -2113,6 +2386,14 @@ class PHashType < PCollectionType
2113
2386
  self == EMPTY
2114
2387
  end
2115
2388
 
2389
+ def resolve(type_parser, loader)
2390
+ rkey_type = @key_type
2391
+ rkey_type = rkey_type.resolve(type_parser, loader) unless rkey_type.nil?
2392
+ rvalue_type = @element_type
2393
+ rvalue_type = rvalue_type.resolve(type_parser, loader) unless rvalue_type.nil?
2394
+ rkey_type.equal?(@key_type) && rvalue_type.equal?(@element_type) ? self : self.class.new(rkey_type, rvalue_type, @size_type)
2395
+ end
2396
+
2116
2397
  # Returns a new function that produces a Hash
2117
2398
  #
2118
2399
  def self.new_function(_, loader)
@@ -2196,6 +2477,10 @@ end
2196
2477
  class PVariantType < PAnyType
2197
2478
  include Enumerable
2198
2479
 
2480
+ def self.register_ptype(loader, ir)
2481
+ create_ptype(loader, ir, 'AnyType', 'types' => PArrayType.new(PType::DEFAULT))
2482
+ end
2483
+
2199
2484
  attr_reader :types
2200
2485
 
2201
2486
  # Checks if the number of unique types in the given array is greater than one, and if so
@@ -2422,7 +2707,7 @@ class PVariantType < PAnyType
2422
2707
  if array.size > 1
2423
2708
  parts = array.partition {|t| t.is_a?(PSemVerType) }
2424
2709
  ranges = parts[0]
2425
- array = [PSemVerType.new(*ranges.map(&:ranges).flatten)] + parts[1] if ranges.size > 1
2710
+ array = [PSemVerType.new(ranges.map(&:ranges).flatten)] + parts[1] if ranges.size > 1
2426
2711
  end
2427
2712
  array
2428
2713
  end
@@ -2452,6 +2737,9 @@ end
2452
2737
  # @api public
2453
2738
  #
2454
2739
  class PCatalogEntryType < PAnyType
2740
+ def self.register_ptype(loader, ir)
2741
+ create_ptype(loader, ir, 'AnyType')
2742
+ end
2455
2743
 
2456
2744
  DEFAULT = PCatalogEntryType.new
2457
2745
 
@@ -2472,6 +2760,15 @@ end
2472
2760
  class PHostClassType < PCatalogEntryType
2473
2761
  attr_reader :class_name
2474
2762
 
2763
+ def self.register_ptype(loader, ir)
2764
+ create_ptype(loader, ir, 'CatalogEntryType',
2765
+ 'class_name' => {
2766
+ KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
2767
+ KEY_VALUE => nil
2768
+ }
2769
+ )
2770
+ end
2771
+
2475
2772
  NAME = 'Class'.freeze
2476
2773
 
2477
2774
  def initialize(class_name)
@@ -2485,7 +2782,7 @@ class PHostClassType < PCatalogEntryType
2485
2782
  self.class == o.class && @class_name == o.class_name
2486
2783
  end
2487
2784
 
2488
- def simple_name
2785
+ def self.simple_name
2489
2786
  NAME
2490
2787
  end
2491
2788
 
@@ -2507,6 +2804,20 @@ end
2507
2804
  # @api public
2508
2805
  #
2509
2806
  class PResourceType < PCatalogEntryType
2807
+
2808
+ def self.register_ptype(loader, ir)
2809
+ create_ptype(loader, ir, 'CatalogEntryType',
2810
+ 'type_name' => {
2811
+ KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
2812
+ KEY_VALUE => nil
2813
+ },
2814
+ 'title' => {
2815
+ KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
2816
+ KEY_VALUE => nil
2817
+ }
2818
+ )
2819
+ end
2820
+
2510
2821
  attr_reader :type_name, :title, :downcased_name
2511
2822
 
2512
2823
  def initialize(type_name, title = nil)
@@ -2538,6 +2849,16 @@ end
2538
2849
  # @api public
2539
2850
  #
2540
2851
  class POptionalType < PTypeWithContainedType
2852
+
2853
+ def self.register_ptype(loader, ir)
2854
+ create_ptype(loader, ir, 'CatalogEntryType',
2855
+ 'type' => {
2856
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
2857
+ KEY_VALUE => nil
2858
+ }
2859
+ )
2860
+ end
2861
+
2541
2862
  def optional_type
2542
2863
  @type
2543
2864
  end
@@ -2588,6 +2909,11 @@ class POptionalType < PTypeWithContainedType
2588
2909
  end
2589
2910
 
2590
2911
  class PTypeReferenceType < PAnyType
2912
+
2913
+ def self.register_ptype(loader, ir)
2914
+ create_ptype(loader, ir, 'AnyType', 'type_string' => PStringType::NON_EMPTY)
2915
+ end
2916
+
2591
2917
  attr_reader :type_string
2592
2918
 
2593
2919
  def initialize(type_string)
@@ -2632,6 +2958,18 @@ end
2632
2958
  #
2633
2959
  # @api public
2634
2960
  class PTypeAliasType < PAnyType
2961
+
2962
+ def self.register_ptype(loader, ir)
2963
+ create_ptype(loader, ir, 'AnyType',
2964
+ 'name' => PStringType::NON_EMPTY,
2965
+ 'type_expr' => PAnyType::DEFAULT,
2966
+ 'resolved_type' => {
2967
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
2968
+ KEY_VALUE => nil
2969
+ }
2970
+ )
2971
+ end
2972
+
2635
2973
  attr_reader :name
2636
2974
 
2637
2975
  # @param name [String] The name of the type
@@ -2742,7 +3080,11 @@ class PTypeAliasType < PAnyType
2742
3080
  @resolved_type = PTypeReferenceType::DEFAULT
2743
3081
  @self_recursion = true # assumed while it being found out below
2744
3082
  begin
2745
- @resolved_type = type_parser.interpret(@type_expr, loader).normalize
3083
+ if @type_expr.is_a?(PTypeReferenceType)
3084
+ @resolved_type = @type_expr.resolve(type_parser, loader)
3085
+ else
3086
+ @resolved_type = type_parser.interpret(@type_expr, loader).normalize
3087
+ end
2746
3088
 
2747
3089
  # Find out if this type is recursive. A recursive type has performance implications
2748
3090
  # on several methods and this knowledge is used to avoid that for non-recursive
@@ -2778,7 +3120,7 @@ class PTypeAliasType < PAnyType
2778
3120
  def accept(visitor, guard)
2779
3121
  guarded_recursion(guard, nil) do |g|
2780
3122
  super(visitor, g)
2781
- resolved_type.accept(visitor, g)
3123
+ @resolved_type.accept(visitor, g) unless @resolved_type.nil?
2782
3124
  end
2783
3125
  end
2784
3126
 
@@ -2801,6 +3143,7 @@ class PTypeAliasType < PAnyType
2801
3143
 
2802
3144
  # Delegates to resolved type
2803
3145
  def method_missing(name, *arguments, &block)
3146
+ super if @resolved_type.equal?(PTypeReferenceType::DEFAULT)
2804
3147
  resolved_type.send(name, *arguments, &block)
2805
3148
  end
2806
3149
 
@@ -2814,6 +3157,12 @@ class PTypeAliasType < PAnyType
2814
3157
  resolved_type.really_instance?(o, guard)
2815
3158
  end
2816
3159
 
3160
+ # @return `nil` to prevent serialization of the type_expr used when first initializing this instance
3161
+ # @api private
3162
+ def type_expr
3163
+ nil
3164
+ end
3165
+
2817
3166
  protected
2818
3167
 
2819
3168
  def _assignable?(o, guard)
@@ -2867,9 +3216,13 @@ end
2867
3216
 
2868
3217
  require 'puppet/pops/pcore'
2869
3218
 
2870
- require_relative 'puppet_object'
3219
+ require_relative 'annotatable'
3220
+ require_relative 'p_meta_type'
2871
3221
  require_relative 'p_object_type'
2872
3222
  require_relative 'p_runtime_type'
2873
3223
  require_relative 'p_sem_ver_type'
2874
3224
  require_relative 'p_sem_ver_range_type'
3225
+ require_relative 'p_sensitive_type'
3226
+ require_relative 'p_type_set_type'
3227
+ require_relative 'type_set_reference'
2875
3228
  require_relative 'implementation_registry'