Class: MilkTea::ModuleLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/milk_tea/core/module_loader.rb,
lib/milk_tea/core/module_loader/errors.rb

Defined Under Namespace

Classes: ImportResolution, ImportResolutionError, Program

Constant Summary collapse

PLATFORM_SUFFIXES =
{
  "linux" => :linux,
  "windows" => :windows,
  "wasm" => :wasm,
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(module_roots: [MilkTea.root], package_graph: nil, shared_cache: nil, source_overrides: nil, platform: nil) ⇒ ModuleLoader

Returns a new instance of ModuleLoader.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/milk_tea/core/module_loader.rb', line 93

def initialize(module_roots: [MilkTea.root], package_graph: nil, shared_cache: nil, source_overrides: nil, platform: nil)
  @module_roots = module_roots.map { |root| File.expand_path(root.to_s) }
  @ast_cache = {}
  @parse_cache = {}
  @analysis_cache = {}
  @collecting_analysis_cache = {}
  @collecting_path_errors = {}
  @checking_paths = []
  @forward_bindings = {}
  @platform = self.class.normalize_platform_name(platform)
  @package_graph = package_graph
  @package_manifest_cache = {}
  @shared_cache = shared_cache # Hash or nil; mutated in-place to persist across calls
  @source_overrides = normalize_source_overrides(source_overrides)

  @path_resolver = ModulePathResolver.new(
    module_roots: @module_roots,
    platform: @platform,
    package_graph: @package_graph,
    source_overrides: @source_overrides,
    package_manifest_cache: @package_manifest_cache,
  )
  @binder = ModuleBinder.new
  @async_runtime_installer = AsyncRuntimeInstaller.new(
    resolve_module_path: @path_resolver.method(:resolve_module_path),
    check_block: ->(path, collecting) { collecting ? check_path_collecting_errors(path) : check_path(path) },
    bind_block: @binder.method(:module_binding),
  )
  @prelude_installer = PreludeInstaller.new(
    resolve_module_path: @path_resolver.method(:resolve_module_path),
    check_block: ->(path, collecting) { collecting ? check_path_collecting_errors(path) : check_path(path) },
    bind_block: @binder.method(:module_binding),
  )
end

Class Method Details

.check_file(path, platform: nil) ⇒ Object



22
23
24
# File 'lib/milk_tea/core/module_loader.rb', line 22

def self.check_file(path, platform: nil)
  new(platform:).check_file(path)
end

.check_program(path, platform: nil) ⇒ Object



26
27
28
# File 'lib/milk_tea/core/module_loader.rb', line 26

def self.check_program(path, platform: nil)
  new(platform:).check_program(path)
end

.default_host_platformObject



89
90
91
# File 'lib/milk_tea/core/module_loader.rb', line 89

def self.default_host_platform
  MilkTea.host_platform
end

.effective_platform_for_path(path, platform_override: nil, host_platform: nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/milk_tea/core/module_loader.rb', line 54

def self.effective_platform_for_path(path, platform_override: nil, host_platform: nil)
  normalized_override = normalize_platform_name(platform_override)
  return normalized_override if normalized_override

  suffix_platform = platform_suffix_for_path(path)
  return suffix_platform if suffix_platform

  manifest_platform = PackageManifest.load(path).platform
  return manifest_platform if manifest_platform

  normalize_platform_name(host_platform || default_host_platform)
rescue PackageManifestError
  normalize_platform_name(host_platform || default_host_platform)
end

.load_file(path, platform: nil) ⇒ Object



18
19
20
# File 'lib/milk_tea/core/module_loader.rb', line 18

def self.load_file(path, platform: nil)
  new(platform:).load_file(path)
end

.normalize_platform_name(value) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/milk_tea/core/module_loader.rb', line 30

def self.normalize_platform_name(value)
  return nil if value.nil? || value.to_s.strip.empty?

  case value.to_s.strip.downcase
  when "linux"
    :linux
  when "windows", "win", "win32"
    :windows
  when "wasm", "web", "html5", "browser"
    :wasm
  when "darwin", "macos", "osx"
    :darwin
  else
    raise ArgumentError, "unknown platform #{value}; expected linux|windows|wasm|darwin"
  end
end

.platform_suffix_for_path(path) ⇒ Object



47
48
49
50
51
52
# File 'lib/milk_tea/core/module_loader.rb', line 47

def self.platform_suffix_for_path(path)
  match = File.basename(path.to_s).match(/\.(linux|windows|wasm)\.mt\z/)
  return nil unless match

  PLATFORM_SUFFIXES.fetch(match[1])
end

.raise_platform_conflict!(path, pinned_platform, active_platform, error_class: nil) ⇒ Object

Raises:

  • (error_class || ArgumentError)


383
384
385
386
387
388
389
390
# File 'lib/milk_tea/core/module_loader.rb', line 383

def self.raise_platform_conflict!(path, pinned_platform, active_platform, error_class: nil)
  if error_class == ModuleLoadError
    raise ModuleLoadError.new("source file targets platform #{pinned_platform}; active platform is #{active_platform}", path:)
  end

  message = "source file #{path} targets platform #{pinned_platform}; active platform is #{active_platform}"
  raise(error_class || ArgumentError, message)
end

.resolve_source_path(path, platform: nil, error_class: nil) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/milk_tea/core/module_loader.rb', line 69

def self.resolve_source_path(path, platform: nil, error_class: nil)
  expanded_path = File.expand_path(path.to_s)
  normalized_platform = platform.nil? ? nil : normalize_platform_name(platform)
  pinned_platform = platform_suffix_for_path(expanded_path)

  if pinned_platform
    if normalized_platform && normalized_platform != pinned_platform
      raise_platform_conflict!(expanded_path, pinned_platform, normalized_platform, error_class:)
    end
    return expanded_path
  end

  return expanded_path unless normalized_platform && expanded_path.end_with?(".mt")

  variant_path = expanded_path.sub(/\.mt\z/, ".#{normalized_platform}.mt")
  return variant_path if File.file?(variant_path)

  expanded_path
end

Instance Method Details

#build_global_import_index(ast) ⇒ Object



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/milk_tea/core/module_loader.rb', line 318

def build_global_import_index(ast)
  index = {}
  current_imports = ast.imports.map { |import| import.path.to_s }.to_set

  @analysis_cache.each_value do |analysis|
    next unless analysis
    next unless analysis.module_name

    mod_name = analysis.module_name.to_s
    next if current_imports.include?(mod_name)
    next if mod_name == ast.module_name.to_s

    types = analysis.respond_to?(:types) ? analysis.types : {}
    types.each_key do |type_name|
      type_str = type_name.to_s
      index[type_str] ||= []
      index[type_str] << mod_name unless index[type_str].include?(mod_name)
    end
  end

  index
end

#check_file(path) ⇒ Object



133
134
135
# File 'lib/milk_tea/core/module_loader.rb', line 133

def check_file(path)
  check_program(path).root_analysis
end

#check_level_parallel(paths) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/milk_tea/core/module_loader.rb', line 279

def check_level_parallel(paths)
  threads = paths.map do |resolved_path|
    Thread.new do
      Thread.current[:resolved_path] = resolved_path
      begin
        analysis = check_path(resolved_path)
        Thread.current[:analysis] = analysis
      rescue ModuleLoadError, PackageLockError, SemanticError => e
        Thread.current[:error] = e
      end
    end
  end

  threads.each(&:join)

  paths.zip(threads).each do |resolved_path, t|
    raise t[:error] if t[:error]
  end
end

#check_module_cache(path, extra_cache: nil) ⇒ Object



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/milk_tea/core/module_loader.rb', line 432

def check_module_cache(path, extra_cache: nil)
  resolved_path = self.class.resolve_source_path(path, platform: @platform, error_class: ModuleLoadError)

  return [resolved_path, nil, @analysis_cache[resolved_path]] if @analysis_cache.key?(resolved_path)
  return [resolved_path, nil, extra_cache[resolved_path]] if extra_cache&.key?(resolved_path)

  if use_shared_cache?
    entry = @shared_cache[resolved_path]
    if entry
      mtime = File.mtime(resolved_path).to_f rescue nil
      if mtime && entry[:mtime] == mtime
        @analysis_cache[resolved_path] = entry[:analysis]
        return [resolved_path, nil, entry[:analysis]]
      end
    end
  end

  ast = load_file(resolved_path)
  [resolved_path, ast, nil]
end

#check_path(path) ⇒ Object



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/milk_tea/core/module_loader.rb', line 392

def check_path(path)
  resolved_path, ast, cached = check_module_cache(path)
  return cached if cached

  if @checking_paths.include?(resolved_path) && !@forward_bindings.key?(resolved_path)
    raise ModuleLoadError.new("circular import not resolvable: module #{@parse_cache[resolved_path]&.module_name || File.basename(path)}", path: resolved_path)
  end

  @checking_paths << resolved_path
  imported_modules = imported_modules_for_ast(ast, importer_path: resolved_path)
  global_index = build_global_import_index(ast)
  analysis = SemanticAnalyzer.check(ast, imported_modules:, path: resolved_path, global_import_index: global_index)
  @analysis_cache[resolved_path] = analysis
  update_shared_cache(resolved_path, analysis)
  analysis
ensure
  @checking_paths.pop
end

#check_path_collecting_errors(path) ⇒ Object



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/milk_tea/core/module_loader.rb', line 411

def check_path_collecting_errors(path)
  resolved_path, ast, cached = check_module_cache(path, extra_cache: @collecting_analysis_cache)
  return cached if cached

  if @checking_paths.include?(resolved_path) && !@forward_bindings.key?(resolved_path)
    raise ModuleLoadError.new("circular import not resolvable: module #{@parse_cache[resolved_path]&.module_name || File.basename(path)}", path: resolved_path)
  end

  @checking_paths << resolved_path
  imported_modules = imported_modules_for_ast_collecting_errors(ast, importer_path: resolved_path).modules
  result = SemanticAnalyzer.check_collecting_errors(ast, imported_modules:, path: resolved_path)
  analysis = result[:analysis]
  raise(result[:errors].first || ModuleLoadError.new("module analysis unavailable", path: resolved_path)) unless analysis

  @collecting_path_errors[resolved_path] = result[:errors]
  @collecting_analysis_cache[resolved_path] = analysis
  analysis
ensure
  @checking_paths.pop
end

#check_program(path) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/milk_tea/core/module_loader.rb', line 137

def check_program(path)
  Types::Registry.reset!
  requested_path = File.expand_path(path)
  previous_platform = @platform
  @platform ||= self.class.platform_suffix_for_path(requested_path)
  root_path = self.class.resolve_source_path(requested_path, platform: @platform, error_class: ModuleLoadError)

  check_program_parallel(root_path)

  root_analysis = @analysis_cache.fetch(root_path)
  analyses_by_module_name = @analysis_cache.each_value.each_with_object({}) do |analysis, modules|
    next unless analysis.module_name

    modules[analysis.module_name] = analysis
  end

  Program.new(
    root_path:,
    root_analysis:,
    analyses_by_path: @analysis_cache.dup.freeze,
    analyses_by_module_name: analyses_by_module_name.freeze,
  )
ensure
  @platform = previous_platform
end

#check_program_parallel(root_path) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/milk_tea/core/module_loader.rb', line 163

def check_program_parallel(root_path)
  # Phase 1: Parse all transitive modules (sequential)
  parse_all(root_path)

  # Phase 2: Build dependency graph from parsed ASTs
  graph = {}
  @parse_cache.each_key do |resolved_path|
    ast = @parse_cache[resolved_path]
    deps = ast.imports.map do |import|
      @path_resolver.resolve_module_path(import.path.to_s, importer_path: resolved_path, importer_module_name: ast.module_name.to_s)
    end
    graph[resolved_path] = deps
  end

  # Phase 3: Topological sort into independent levels
  levels = topo_sort_levels(graph)

  # Pre-register forward bindings for cycle members
  all_checked = levels.flatten.to_set
  cycle_members = graph.keys.reject { |p| all_checked.include?(p) }
  cycle_members.each do |resolved_path|
    ast = @parse_cache[resolved_path]
    @forward_bindings[resolved_path] = create_forward_binding(ast)
  end

  # Phase 4: Check cycle members with iterative refinement
  # Pass 1: Check with forward bindings — registers type declarations.
  # SemanticError is expected (forward types lack fields/constructors)
  # but ModuleLoadError indicates a broken dependency graph.
  cycle_members.each do |resolved_path|
    check_path(resolved_path)
  rescue SemanticError
    # Forward types can't satisfy constructors. Pass 2 will retry.
  end

  # Update forward type objects in-place with field/arm info from the
  # real analyses. This way, all references to forward types (function
  # return types, struct field types, etc.) automatically see the full
  # type information without needing to replace the objects themselves.
  cycle_members.each do |resolved_path|
    analysis = @analysis_cache[resolved_path]
    next unless analysis

    fw_binding = @forward_bindings[resolved_path]
    next unless fw_binding

    analysis.types.each do |name, real_type|
      fw_type = fw_binding.types[name]
      next unless fw_type

      if real_type.respond_to?(:fields) && fw_type.respond_to?(:define_fields)
        fw_type.define_fields(real_type.fields) unless real_type.fields.empty?
      end
      if real_type.respond_to?(:arms) && fw_type.respond_to?(:define_arms)
        fw_type.define_arms(real_type.arms) unless real_type.arms.empty?
      end
    end
  end

  # Pass 2: Re-check with populated types — now cycle members see
  # complete type information for each other.
  cycle_members.each do |resolved_path|
    previous = @analysis_cache.delete(resolved_path)
    check_path(resolved_path)
  rescue SemanticError
    @analysis_cache[resolved_path] = previous if previous
  end
  @forward_bindings.clear

  # Phase 5: Check acyclic modules (they see fully-checked analyses for all imports)
  levels.each do |level_paths|
    if level_paths.length == 1
      check_path(level_paths.first)
    else
      check_level_parallel(level_paths)
    end
  end
end

#collecting_path_errorsObject

Errors collected per analyzed import path during collecting-mode checks. Populated by #check_path_collecting_errors; used by the CLI check command to surface errors in a single file's imported modules (otherwise only reported when that module is checked directly).



379
380
381
# File 'lib/milk_tea/core/module_loader.rb', line 379

def collecting_path_errors
  @collecting_path_errors
end

#create_forward_binding(ast) ⇒ Object



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/milk_tea/core/module_loader.rb', line 519

def create_forward_binding(ast)
  module_name = ast.module_name.to_s
  types = {}

  ast.declarations.each do |decl|
    case decl
    when AST::StructDecl
      types[decl.name] = Types::Struct.new(decl.name, module_name:)
    when AST::VariantDecl
      types[decl.name] = Types::Variant.new(decl.name, module_name:)
    when AST::EnumDecl
      types[decl.name] = Types::Enum.new(decl.name, module_name:)
    when AST::FlagsDecl
      types[decl.name] = Types::Flags.new(decl.name, module_name:)
    when AST::OpaqueDecl
      types[decl.name] = Types::Opaque.new(decl.name, module_name:, external: false)
    end
  end

  ModuleBinding.new(
    name: module_name, types:, type_declarations: {},
    interfaces: {}, attributes: {}, attribute_applications: {},
    values: {}, functions: {}, methods: {},
    implemented_interfaces: {}, imports: {},
    private_types: {}, private_interfaces: {}, private_attributes: {},
    private_values: {}, private_functions: {}, private_methods: {},
    private_implemented_interfaces: {},
  )
end

#imported_modules_for_ast(ast, importer_path: nil) ⇒ Object



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/milk_tea/core/module_loader.rb', line 299

def imported_modules_for_ast(ast, importer_path: nil)
  modules = {}

  ast.imports.each do |import|
    import_path = @path_resolver.resolve_module_path(import.path.to_s, importer_path:, importer_module_name: ast.module_name.to_s)

    if @forward_bindings.key?(import_path)
      modules[import.path.to_s] = @forward_bindings[import_path]
    else
      import_analysis = check_path(import_path)
      modules[import.path.to_s] = @binder.module_binding(import_analysis)
    end
  end

  @async_runtime_installer.install_async_runtime_dependency!(ast, modules, importer_path:, collecting_errors: false)
  @prelude_installer.install_prelude_modules!(ast, modules, importer_path:, collecting_errors: false)
  modules.freeze
end

#imported_modules_for_ast_collecting_errors(ast, importer_path: nil) ⇒ Object



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/milk_tea/core/module_loader.rb', line 341

def imported_modules_for_ast_collecting_errors(ast, importer_path: nil)
  modules = {}
  errors = []

  ast.imports.each do |import|
    begin
      import_path = @path_resolver.resolve_module_path(import.path.to_s, importer_path:, importer_module_name: ast.module_name.to_s)

      if @forward_bindings.key?(import_path)
        modules[import.path.to_s] = @forward_bindings[import_path]
      else
        import_analysis = check_path_collecting_errors(import_path)
        modules[import.path.to_s] = @binder.module_binding(import_analysis)
      end
    rescue ModuleLoadError, PackageLockError, SemanticError => e
      errors << ImportResolutionError.new(import:, error: e)
    end
  end

  begin
    @async_runtime_installer.install_async_runtime_dependency!(ast, modules, importer_path:, collecting_errors: true)
  rescue ModuleLoadError, PackageLockError => e
    errors << ImportResolutionError.new(import: nil, error: e)
  end

  begin
    @prelude_installer.install_prelude_modules!(ast, modules, importer_path:, collecting_errors: true)
  rescue ModuleLoadError, PackageLockError => e
    errors << ImportResolutionError.new(import: nil, error: e)
  end

  ImportResolution.new(modules: modules.freeze, errors: errors.freeze)
end

#inferred_module_name_for_path(path) ⇒ Object



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/milk_tea/core/module_loader.rb', line 487

def inferred_module_name_for_path(path)
  manifest = begin
    PackageManifest.load(path)
  rescue PackageManifestError
    nil
  end

  if manifest && path_within_root?(path, manifest.source_root)
    return module_name_for_path(path, manifest.source_root)
  end

  matching_root = @module_roots
    .select { |root| path_within_root?(path, root) }
    .max_by(&:length)
  return module_name_for_path(path, matching_root) if matching_root

  File.basename(path).sub(/\.(linux|windows|wasm)\.mt\z/, ".mt").sub(/\.mt\z/, "")
end

#load_file(path) ⇒ Object



128
129
130
131
# File 'lib/milk_tea/core/module_loader.rb', line 128

def load_file(path)
  resolved_path = self.class.resolve_source_path(path, platform: @platform, error_class: ModuleLoadError)
  @ast_cache[resolved_path] ||= parse_file(resolved_path)
end

#module_name_for_path(path, root) ⇒ Object



506
507
508
509
510
511
# File 'lib/milk_tea/core/module_loader.rb', line 506

def module_name_for_path(path, root)
  relative_path = path.delete_prefix(File.expand_path(root) + File::SEPARATOR)
  relative_path = File.basename(path) if relative_path == path
  relative_path = relative_path.sub(/\.(linux|windows|wasm)\.mt\z/, '.mt')
  relative_path.sub(/\.mt\z/, '').split(File::SEPARATOR).join('.')
end

#normalize_source_overrides(source_overrides) ⇒ Object



479
480
481
482
483
484
485
# File 'lib/milk_tea/core/module_loader.rb', line 479

def normalize_source_overrides(source_overrides)
  return {} unless source_overrides

  source_overrides.each_with_object({}) do |(path, source), overrides|
    overrides[File.expand_path(path.to_s)] = source.to_s
  end
end

#parse_all(resolved_path) ⇒ Object



242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/milk_tea/core/module_loader.rb', line 242

def parse_all(resolved_path)
  return if @parse_cache.key?(resolved_path)

  @checking_paths << resolved_path
  ast = load_file(resolved_path)
  @parse_cache[resolved_path] = ast

  ast.imports.each do |import|
    import_path = @path_resolver.resolve_module_path(import.path.to_s, importer_path: resolved_path, importer_module_name: ast.module_name.to_s)
    parse_all(import_path)
  end
ensure
  @checking_paths.pop
end

#parse_file(path) ⇒ Object



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/milk_tea/core/module_loader.rb', line 460

def parse_file(path)
  source = @source_overrides.fetch(path) { File.read(path) }
  ast = Parser.parse(source, path: path)
  inferred_module_name = inferred_module_name_for_path(path)
  AST::SourceFile.new(
    module_name: AST::QualifiedName.new(inferred_module_name.split(".")),
    module_kind: ast.module_kind,
    imports: ast.imports,
    directives: ast.directives,
    declarations: ast.declarations,
    line: ast.line,
    node_ids: ast.node_ids,
  )
rescue Errno::ENOENT
  raise ModuleLoadError.new("source file not found", path: path)
rescue Errno::EISDIR
  raise ModuleLoadError.new("expected a source file, got a directory", path: path)
end

#path_within_root?(path, root) ⇒ Boolean

Returns:

  • (Boolean)


513
514
515
516
517
# File 'lib/milk_tea/core/module_loader.rb', line 513

def path_within_root?(path, root)
  normalized_path = File.expand_path(path)
  normalized_root = File.expand_path(root)
  normalized_path == normalized_root || normalized_path.start_with?(normalized_root + File::SEPARATOR)
end

#topo_sort_levels(graph) ⇒ Object



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/milk_tea/core/module_loader.rb', line 257

def topo_sort_levels(graph)
  in_degree = {}
  graph.each_key { |node| in_degree[node] = 0 }
  graph.each_value do |deps|
    deps.each { |dep| in_degree[dep] = (in_degree[dep] || 0) + 1 }
  end

  levels = []
  remaining = graph.keys.to_set
  until remaining.empty?
    level = remaining.select { |node| (in_degree[node] || 0) == 0 }
    break if level.empty?

    levels << level
    level.each do |node|
      remaining.delete(node)
      (graph[node] || []).each { |dep| in_degree[dep] -= 1 }
    end
  end
  levels
end

#update_shared_cache(resolved_path, analysis) ⇒ Object



453
454
455
456
457
458
# File 'lib/milk_tea/core/module_loader.rb', line 453

def update_shared_cache(resolved_path, analysis)
  return unless use_shared_cache?

  mtime = File.mtime(resolved_path).to_f rescue nil
  @shared_cache[resolved_path] = { mtime:, analysis: } if mtime
end

#use_shared_cache?Boolean

Returns:

  • (Boolean)


549
550
551
# File 'lib/milk_tea/core/module_loader.rb', line 549

def use_shared_cache?
  @shared_cache && @source_overrides.empty?
end