From d61601cbffd773eda07d6ed8cafec23e10f03c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Tue, 25 Feb 2025 18:26:53 +0100 Subject: [PATCH] implement missing pieces of resolution --- .../analyse/types/scope/StaticImportExportScope.java | 10 ++++++++++ .../analyse/types/scope/StaticMethodResolution.java | 8 ++------ .../pass/analyse/types/scope/StaticModuleScope.java | 5 +++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticImportExportScope.java b/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticImportExportScope.java index 15230d67224f..8aab52ddd1e6 100644 --- a/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticImportExportScope.java +++ b/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticImportExportScope.java @@ -64,6 +64,16 @@ public TypeRepresentation getExportedMethod(TypeScopeReference type, String name // TODO filtering only/hiding (see above) - for now we just return everything return methodResolutionAlgorithm.getExportedMethod(referredModuleScope, type, name); } + + public TypeRepresentation getConversionForType( + TypeScopeReference target, TypeScopeReference source) { + return referredModuleScope.getConversionFor(target, source); + } + + public TypeRepresentation getExportedConversion( + TypeScopeReference target, TypeScopeReference source) { + return methodResolutionAlgorithm.getExportedConversion(referredModuleScope, target, source); + } } public QualifiedName getReferredModuleName() { diff --git a/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticMethodResolution.java b/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticMethodResolution.java index 877f29ac4145..79bd5974b844 100644 --- a/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticMethodResolution.java +++ b/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticMethodResolution.java @@ -77,17 +77,13 @@ protected TypeRepresentation getExportedMethodFromScope( @Override protected TypeRepresentation getConversionFromScope( StaticImportExportScope scope, TypeScopeReference target, TypeScopeReference source) { - // TODO conversions can also have optional arguments, we should include this - // boolean hasConversion = scope.resolve(moduleResolver, this).getMethodForType() - // TODO... - return null; + return scope.resolve(moduleResolver, this).getConversionForType(target, source); } @Override protected TypeRepresentation getExportedConversionFromScope( StaticImportExportScope scope, TypeScopeReference target, TypeScopeReference source) { - // TODO conversions in static analysis - return null; + return scope.resolve(moduleResolver, this).getExportedConversion(target, source); } @Override diff --git a/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticModuleScope.java b/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticModuleScope.java index 6d0482ceae34..d5c96627179b 100644 --- a/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticModuleScope.java +++ b/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/types/scope/StaticModuleScope.java @@ -224,4 +224,9 @@ public TypeRepresentation getConversionFor(TypeScopeReference target, TypeScopeR public AtomTypeDefinition getType(String name) { return typesDefinedHere.get(name); } + + @Override + public String toString() { + return "StaticModuleScope{" + moduleName + "}"; + } }