From 9d8b87310feaf1ce74003a78cc41a73b69a2e998 Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Wed, 11 Sep 2024 16:16:29 +0200 Subject: [PATCH 1/3] fe: remove LibraryFeature dependency on Types.resolved --- src/dev/flang/fe/LibraryFeature.java | 3 +-- src/dev/flang/fe/LibraryModule.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dev/flang/fe/LibraryFeature.java b/src/dev/flang/fe/LibraryFeature.java index 8c9cc80a0e..935578a71a 100644 --- a/src/dev/flang/fe/LibraryFeature.java +++ b/src/dev/flang/fe/LibraryFeature.java @@ -52,7 +52,6 @@ import dev.flang.ast.FeatureVisitor; import dev.flang.ast.InlineArray; import dev.flang.ast.Tag; -import dev.flang.ast.Types; import dev.flang.ast.Universe; import dev.flang.ast.Visi; @@ -422,7 +421,7 @@ public AbstractType resultType() } else if (isChoice()) { - return Types.resolved.t_void; + return _libModule.lookupFeature(_libModule.libraryUniverse(), FeatureName.get("void", 0), null).selfType(); } else { diff --git a/src/dev/flang/fe/LibraryModule.java b/src/dev/flang/fe/LibraryModule.java index 6049c410a3..9e4f7b1177 100644 --- a/src/dev/flang/fe/LibraryModule.java +++ b/src/dev/flang/fe/LibraryModule.java @@ -417,7 +417,7 @@ List features(AbstractFeature outer) /** * get the universe as persisted in this fum-file */ - private LibraryFeature libraryUniverse() + public LibraryFeature libraryUniverse() { return (LibraryFeature)innerFeatures(declFeaturesInnerPos(moduleDeclFeaturesPos())).get(0); } From e46923952e1283f0fd95ac2d5d816fd77bdb222b Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Thu, 12 Sep 2024 17:05:57 +0200 Subject: [PATCH 2/3] wip --- src/dev/flang/air/Clazz.java | 1 - src/dev/flang/ast/AbstractType.java | 9 +- src/dev/flang/ast/Types.java | 93 +++++++++++++ src/dev/flang/fe/FrontEnd.java | 123 ++++++++++-------- src/dev/flang/fe/LibraryFeature.java | 21 ++- src/dev/flang/fe/LibraryModule.java | 25 ++-- src/dev/flang/fe/Module.java | 46 +++---- src/dev/flang/fe/SourceModule.java | 41 +++--- src/dev/flang/fuir/analysis/dfa/Env.java | 2 +- src/dev/flang/tools/CheckIntrinsics.java | 4 +- src/dev/flang/tools/fzjava/FZJava.java | 2 +- ..._time_type_casts_negative2.fz.expected_err | 6 +- .../test_local_mutate_neg.fz.expected_err | 2 +- .../reg_issue2273.fz.expected_err | 4 +- .../reg_issue2564.fz.expected_err | 4 +- .../reg_issue3147.fz.expected_err | 6 +- .../reg_issue3199.fz.expected_err | 4 +- .../reg_issue3359.fz.expected_err | 58 ++++----- .../reg_issue348/reg_issue348.fz.expected_err | 4 +- 19 files changed, 288 insertions(+), 167 deletions(-) diff --git a/src/dev/flang/air/Clazz.java b/src/dev/flang/air/Clazz.java index e493c6926f..90f4375b49 100644 --- a/src/dev/flang/air/Clazz.java +++ b/src/dev/flang/air/Clazz.java @@ -152,7 +152,6 @@ public boolean action(AbstractMatch m, AbstractCase c) { var ac = actualClazzes(sc, null); var innerClazz = ac[0]; - var T = innerClazz.actualGenerics()[0]; var cf = innerClazz.feature(); if (CHECKS) check (cf == Types.resolved.f_Type_infix_colon_true || diff --git a/src/dev/flang/ast/AbstractType.java b/src/dev/flang/ast/AbstractType.java index c116dc7cff..d8f60fca3c 100644 --- a/src/dev/flang/ast/AbstractType.java +++ b/src/dev/flang/ast/AbstractType.java @@ -1313,7 +1313,9 @@ public int compareToIgnoreOuter(AbstractType other) if (PRECONDITIONS) require (checkedForGeneric(), other != null, - other.checkedForGeneric()); + other.checkedForGeneric(), + !(this instanceof UnresolvedType), + !(other instanceof UnresolvedType)); int result = 0; @@ -1561,10 +1563,13 @@ AbstractType typeType(Resolution res) var g = new List(this); g.addAll(generics()); + var tf = res != null ? fot.typeFeature(res) : fot.typeFeature(); + if (CHECKS) check + (tf != null); result = ResolvedNormalType.create(g, g, outer().typeType(res), - res != null ? fot.typeFeature(res) : fot.typeFeature()); + tf); } return result; } diff --git a/src/dev/flang/ast/Types.java b/src/dev/flang/ast/Types.java index 31cc3ee5ac..1e6f218cca 100644 --- a/src/dev/flang/ast/Types.java +++ b/src/dev/flang/ast/Types.java @@ -298,6 +298,99 @@ public Resolved(SrcModule mod, CreateType ct, AbstractFeature universe) res.resolveTypes(t.feature()); } } + public static interface LookupFeature + { + AbstractFeature lookup(AbstractFeature target, FeatureName fn); + } + public Resolved(LookupFeature lf, AbstractFeature universe) + { + this.universe = universe; + t_i8 = lookup(lf, "i8", 1).selfType(); + t_i16 = lookup(lf, "i16", 1).selfType(); + t_i32 = lookup(lf, "i32", 1).selfType(); + t_i64 = lookup(lf, "i64", 1).selfType(); + t_u8 = lookup(lf, "u8", 1).selfType(); + t_u16 = lookup(lf, "u16", 1).selfType(); + t_u32 = lookup(lf, "u32", 1).selfType(); + t_u64 = lookup(lf, "u64", 1).selfType(); + t_f32 = lookup(lf, "f32", 1).selfType(); + t_f64 = lookup(lf, "f64", 1).selfType(); + t_bool = lookup(lf, "bool", 0).selfType(); + t_fuzion = lookup(lf, "fuzion", 0).selfType(); + t_String = lookup(lf, FuzionConstants.STRING_NAME, 0).selfType(); + t_Const_String = lookup(lf, "Const_String", 0).selfType(); + t_Any = lookup(lf, FuzionConstants.ANY_NAME, 0).selfType(); + t_unit = lookup(lf, FuzionConstants.UNIT_NAME, 0).selfType(); + t_void = lookup(lf, "void", 0).selfType(); + t_codepoint = lookup(lf, "codepoint", 1).selfType(); + f_id = lookup(lf, "id", 2); + f_void = lookup(lf, "void", 0); + f_choice = lookup(lf, "choice", 1); + f_TRUE = lookup(lf, "TRUE", 0); + f_FALSE = lookup(lf, "FALSE", 0); + f_true = lookup(lf, "true", 0); + f_false = lookup(lf, "false", 0); + f_bool = lookup(lf, "bool", 0); + f_bool_NOT = null; + f_bool_AND = null; + f_bool_OR = null; + f_bool_IMPLIES = null; + f_bool_TERNARY = null; + f_Const_String_utf8_data = lookup(lf, lookup(lf, "Const_String", 0), "utf8_data", 0); + f_debug = lookup(lf, "debug", 0); + f_debug_level = lookup(lf, "debug_level", 0); + f_Function = lookup(lf, FUNCTION_NAME, 2); + f_Function_call = lookup(lf, f_Function, "call", 1); + f_safety = lookup(lf, "safety", 0); + f_array = lookup(lf, "array", 5); + f_array_internal_array = lookup(lf, f_array, "internal_array", 0); + f_error = lookup(lf, "error", 1); + f_error_msg = lookup(lf, f_error, "msg", 0); + f_fuzion = lookup(lf, "fuzion", 0); + f_fuzion_java = lookup(lf, f_fuzion, "java", 0); + f_fuzion_Java_Object = lookup(lf, f_fuzion_java, "Java_Object", 1); + f_fuzion_Java_Object_Ref = lookup(lf, f_fuzion_Java_Object, "Java_Ref", 0); + f_fuzion_sys = lookup(lf, f_fuzion, "sys", 0); + f_fuzion_sys_array = lookup(lf, f_fuzion_sys, "internal_array", 3); + f_fuzion_sys_array_data = lookup(lf, f_fuzion_sys_array, "data", 0); + f_fuzion_sys_array_length = lookup(lf, f_fuzion_sys_array, "length", 0); + f_concur = lookup(lf, "concur", 0); + f_concur_atomic = lookup(lf, f_concur, "atomic", 2); + f_concur_atomic_v = lookup(lf, f_concur_atomic, "v", 0); + f_Type = lookup(lf, "Type", 0); + f_Type_infix_colon = lookup(lf, f_Type, "infix :", 1); + f_Type_infix_colon_true = lookup(lf, f_Type, "infix_colon_true", 1); + f_Type_infix_colon_false = lookup(lf, f_Type, "infix_colon_false", 1); + f_type_as_value = lookup(lf, "type_as_value", 1); + f_Lazy = lookup(lf, LAZY_NAME, 1); + f_Unary = lookup(lf, UNARY_NAME, 2); + f_auto_unwrap = lookup(lf, "auto_unwrap", 2); + resolved = this; + numericTypes = new TreeSet(new List<>( + t_i8, + t_i16, + t_i32, + t_i64, + t_u8, + t_u16, + t_u32, + t_u64, + t_f32, + t_f64)); + ((ArtificialBuiltInType) t_ADDRESS ).resolveArtificialType(lookup(lf, FuzionConstants.ANY_NAME, 0)); + ((ArtificialBuiltInType) t_UNDEFINED).resolveArtificialType(universe); + ((ArtificialBuiltInType) t_ERROR ).resolveArtificialType(f_ERROR); + } + private AbstractFeature lookup(LookupFeature lf, AbstractFeature target, String name, int argCount) + { + var result = lf.lookup(target, FeatureName.get(name, argCount)); + check(result != null); + return result; + } + private AbstractFeature lookup(LookupFeature lf, String name, int argCount) + { + return lookup(lf, universe, name, argCount); + } } diff --git a/src/dev/flang/fe/FrontEnd.java b/src/dev/flang/fe/FrontEnd.java index a969df8d7e..64bf818d6f 100644 --- a/src/dev/flang/fe/FrontEnd.java +++ b/src/dev/flang/fe/FrontEnd.java @@ -55,7 +55,6 @@ import dev.flang.util.ANY; import dev.flang.util.Errors; import dev.flang.util.FuzionConstants; -import dev.flang.util.List; import dev.flang.util.SourceDir; @@ -70,9 +69,6 @@ public class FrontEnd extends ANY /*---------------------------- constants ----------------------------*/ - static final FeatureName UNIVERSE_NAME = FeatureName.get(FuzionConstants.UNIVERSE_NAME, 0); - - /** * Offset added to global indices to detect false usage of these early on. */ @@ -94,6 +90,8 @@ public class FrontEnd extends ANY */ class Universe extends Feature { + private final FeatureName _fn = FeatureName.get(FuzionConstants.UNIVERSE_NAME, 0); + { setState(State.LOADING); } public boolean isUniverse() { @@ -102,7 +100,7 @@ public boolean isUniverse() public FeatureName featureName() { - return UNIVERSE_NAME; + return _fn; } } @@ -115,18 +113,6 @@ public FeatureName featureName() public final FrontEndOptions _options; - /** - * The universe. - */ - public final AbstractFeature _universe; - - - /** - * The base module if it was loaded from base.fum, null otherwise. - */ - public final LibraryModule _baseModule; - - /** * The library modules loaded so far. Maps the module name, e.g. "base" to * the corresponding LibraryModule instance. @@ -137,7 +123,7 @@ public FeatureName featureName() /** * The module we are compiling. null if !options._loadSources or Errors.count() != 0 */ - private final SourceModule _sourceModule; + private SourceModule _sourceModule; /** @@ -146,6 +132,12 @@ public FeatureName featureName() private int _totalModuleData = 0; + /** + * The compiled main module. + */ + private LibraryModule _mainModule; + + /*-------------------------- constructors ---------------------------*/ @@ -155,16 +147,8 @@ public FeatureName featureName() public FrontEnd(FrontEndOptions options) { _options = options; - Types.reset(options); - FeatureAndOuter.reset(); - Errors.reset(); - FeatureName.reset(); - Expr.reset(); - Call.reset(); - Contract.reset(); - HasGlobalIndex.reset(); + reset(); var universe = new Universe(); - _universe = universe; var sourcePaths = options.sourcePaths(); var sourceDirs = new SourceDir[sourcePaths.length + options._modules.size()]; @@ -172,25 +156,12 @@ public FrontEnd(FrontEndOptions options) { sourceDirs[i] = new SourceDir(sourcePaths[i]); } - var lms = new List(); - if (options._loadBaseLib) - { - _baseModule = module(FuzionConstants.BASE_MODULE_NAME, modulePath(FuzionConstants.BASE_MODULE_NAME)); - if (_baseModule != null) - { - lms.add(_baseModule); - } - } - else - { - _baseModule = null; - } - lms.addAll(options._modules.stream().map(mn -> loadModule(mn)) - .filter(m -> m != null) - .toList()); - var dependsOn = lms.toArray(LibraryModule[]::new); + + loadModules(universe); + if (options._loadSources) { + var dependsOn = _modules.values().toArray(LibraryModule[]::new); _sourceModule = new SourceModule(options, sourceDirs, dependsOn, universe); _sourceModule.createASTandResolve(); } @@ -201,6 +172,33 @@ public FrontEnd(FrontEndOptions options) } + private void loadModules(Universe universe) + { + if (_options._loadBaseLib) + { + module(FuzionConstants.BASE_MODULE_NAME, modulePath(FuzionConstants.BASE_MODULE_NAME), universe); + } + _options._modules.stream().forEach(mn -> loadModule(mn, universe)); + } + + + private void reset() + { + _totalModuleData = 0; + Types.reset(_options); + FeatureAndOuter.reset(); + Errors.reset(); + FeatureName.reset(); + Expr.reset(); + Call.reset(); + Contract.reset(); + HasGlobalIndex.reset(); + _sourceModule = null; + _modules.clear(); + _mainModule = null; + } + + /** * Determine the path of the base modules, "$(FUZION)/modules". */ @@ -236,13 +234,13 @@ private Path modulePath(String name) /** * Load module from given path. */ - private LibraryModule module(String m, Path p) + private LibraryModule module(String m, Path p, AbstractFeature universe) { LibraryModule result = null; try (var ch = (FileChannel) Files.newByteChannel(p, EnumSet.of(StandardOpenOption.READ))) { var data = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size()); - result = libModule(data, new LibraryModule[0]); + result = libModule(data, universe); if (!m.equals(result.name())) { Errors.error("Module name mismatch for module file '" + p + "' expected name '" + @@ -262,7 +260,7 @@ private LibraryModule module(String m, Path p) /** * create a new LibraryModule from `data` */ - private LibraryModule libModule(ByteBuffer data, LibraryModule[] dependsOn) + private LibraryModule libModule(ByteBuffer data, AbstractFeature universe) { LibraryModule result; var base = _totalModuleData; @@ -270,8 +268,7 @@ private LibraryModule libModule(ByteBuffer data, LibraryModule[] dependsOn) result = new LibraryModule(GLOBAL_INDEX_OFFSET + base, this, data, - dependsOn, - _universe); + universe); return result; } @@ -283,7 +280,7 @@ private LibraryModule libModule(ByteBuffer data, LibraryModule[] dependsOn) * * @return the loaded module or null if it was not found or an error occurred. */ - LibraryModule loadModule(String m) + LibraryModule loadModule(String m, AbstractFeature universe) { var result = _modules.get(m); if (result == null) @@ -291,7 +288,7 @@ LibraryModule loadModule(String m) var p = modulePath(m); if (p != null) { - result = module(m, p); + result = module(m, p, universe); } else { @@ -309,7 +306,9 @@ LibraryModule loadModule(String m) public MIR createMIR() { - return _sourceModule.createMIR(_sourceModule._main); + var main = _sourceModule._main; + var mm = mainModule(); + return mm.createMIR(main); } @@ -331,9 +330,25 @@ public Collection getModules() /** * Get the compiled module main. */ - public Module mainModule() + public LibraryModule mainModule() + { + if (_mainModule == null) + { + _sourceModule.checkMain(); + Errors.showAndExit(); + + var data = _sourceModule.data("main"); + reset(); + _mainModule = libModule(data, null /* use universe of module */); + var ignore = new Types.Resolved((target,fn) -> _mainModule.lookupFeature(target, fn, null), _mainModule.libraryUniverse()); + } + return _mainModule; + } + + + public LibraryModule baseModule() { - return libModule(_sourceModule.data("main"), _modules.values().toArray(new LibraryModule[_modules.size()])); + return _modules.get("base"); } } diff --git a/src/dev/flang/fe/LibraryFeature.java b/src/dev/flang/fe/LibraryFeature.java index 1ff44c0e8c..4c863f19f5 100644 --- a/src/dev/flang/fe/LibraryFeature.java +++ b/src/dev/flang/fe/LibraryFeature.java @@ -229,18 +229,29 @@ public int modifiers() } + @Override + public boolean isUniverse() + { + return featureName().baseName().equals("universe"); + } + + /** * Find the outer feature of this feature. */ public AbstractFeature outer() { - var result = _outer; - if (result == null) + AbstractFeature result = null; + if (!isUniverse()) { - result = _libModule.featureOuter(_index); - _outer = result; - } + result = _outer; + if (result == null) + { + result = _libModule.featureOuter(_index); + _outer = result; + } + } return result; } diff --git a/src/dev/flang/fe/LibraryModule.java b/src/dev/flang/fe/LibraryModule.java index 9440b241fe..cdcac7f82b 100644 --- a/src/dev/flang/fe/LibraryModule.java +++ b/src/dev/flang/fe/LibraryModule.java @@ -35,6 +35,8 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; +import java.util.stream.Collector; +import java.util.stream.Collectors; import dev.flang.ast.AbstractFeature; import dev.flang.ast.AbstractType; @@ -50,6 +52,7 @@ import dev.flang.util.Errors; import dev.flang.util.FuzionConstants; +import dev.flang.util.FuzionConstants.MirExprKind; import dev.flang.util.FuzionOptions; import static dev.flang.util.FuzionConstants.MirExprKind; @@ -162,11 +165,6 @@ public class LibraryModule extends Module implements MirModule private final ModuleRef[] _modules; - /** - * The front end that loaded this module. - */ - private final FrontEnd _fe; - /*-------------------------- constructors ---------------------------*/ @@ -174,15 +172,13 @@ public class LibraryModule extends Module implements MirModule /** * Create LibraryModule for given options and sourceDirs. */ - LibraryModule(int globalBase, FrontEnd fe, ByteBuffer data, LibraryModule[] dependsOn, AbstractFeature universe) + LibraryModule(int globalBase, FrontEnd fe, ByteBuffer data, AbstractFeature universe) { - super(dependsOn); + super(null /* will be set later, need to load first */); _globalBase = globalBase; - _fe = fe; _mir = null; _data = data; - _universe = universe; _sourceFiles = new ArrayList<>(sourceFilesCount()); var sfc = sourceFilesCount(); for (int i = 0; i < sfc; i++) @@ -193,11 +189,14 @@ public class LibraryModule extends Module implements MirModule _modules = new ModuleRef[mrc]; var p = moduleRefsPos(); int moduleOffset = _data.limit(); + this._universe = universe == null ? libraryUniverse() : universe; + if (CHECKS) check + (_universe.isUniverse()); for (int i = 0; i < mrc; i++) { var n = moduleRefName(p); var v = moduleRefVersion(p); - var m = fe.loadModule(n); + var m = fe.loadModule(n, universe()); var mv = m.version(); if (!Arrays.equals(v, mv)) { @@ -208,6 +207,10 @@ public class LibraryModule extends Module implements MirModule moduleOffset = moduleOffset + mr.size(); p = moduleRefNextPos(p); } + _dependsOn = Arrays.stream(_modules) + .map(mr -> mr._module) + .collect(Collectors.toList()) + .toArray(new LibraryModule[_modules.length]); var dm = fe._options._dumpModules; if (DUMP || @@ -260,7 +263,7 @@ int globalIndex(int index) */ private AbstractFeature universe() { - return _fe._universe; + return _universe; } diff --git a/src/dev/flang/fe/Module.java b/src/dev/flang/fe/Module.java index 62ce7455f7..d3b1070f71 100644 --- a/src/dev/flang/fe/Module.java +++ b/src/dev/flang/fe/Module.java @@ -42,12 +42,14 @@ import dev.flang.util.List; import dev.flang.util.SourceFile; +import java.util.Arrays; import java.util.Collection; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; import java.util.function.Consumer; +import java.util.stream.Stream; /** @@ -170,12 +172,6 @@ protected static void add(SortedMap> s, Featu /*----------------------------- methods -----------------------------*/ - /** - * Create the module intermediate representation for this module. - */ - public abstract MIR createMIR(String main); - - /** * Get declared features for given outer Feature as seen by this module. * Result is null if outer has no declared features in this module. @@ -459,6 +455,14 @@ private SortedMap> declaredOrInheritedFeature } } + // This is need for "extension" features + // that are declared in different modules + // than the outer feature: + // e.g. `Any.dt => Any.this.type` + var selfAndModules = Stream + .concat(Arrays.stream(modules), Stream.of(this)) + .toArray(Module[]::new); + // first we search in additional modules for (Module libraryModule : modules) { @@ -466,7 +470,7 @@ private SortedMap> declaredOrInheritedFeature { addDeclaredOrInherited(s, outer, e.getKey(), e.getValue()); } - libraryModule.findInheritedFeatures(s, outer, modules); + libraryModule.findInheritedFeatures(s, outer, selfAndModules); } // then we search in this module @@ -494,6 +498,8 @@ private SortedMap> declaredOrInheritedFeature */ SortedMap> declaredOrInheritedFeatures(AbstractFeature outer) { + if (CHECKS) check + (_dependsOn != null); return this.declaredOrInheritedFeatures(outer, _dependsOn); } @@ -599,8 +605,9 @@ public AbstractFeature lookupFeature(AbstractFeature outer, FeatureName name, Ab * * This is a fix for #978 but it might need to be removed when fixing #932. */ - return result == null && original instanceof Feature of && of._addedLate ? original - : result; + return result == null + ? original + : result; } @@ -609,27 +616,6 @@ public AbstractFeature lookupFeature(AbstractFeature outer, FeatureName name, Ab */ static MIR createMIR(MirModule mirMod, AbstractFeature universe, AbstractFeature main) { - if (main != null && !Errors.any()) - { - if (main.valueArguments().size() != 0) - { - FeErrors.mainFeatureMustNotHaveArguments(main); - } - switch (main.kind()) - { - case Field : FeErrors.mainFeatureMustNotBeField (main); break; - case Abstract : FeErrors.mainFeatureMustNotBeAbstract (main); break; - case Intrinsic: FeErrors.mainFeatureMustNotBeIntrinsic(main); break; - case Choice : FeErrors.mainFeatureMustNotBeChoice (main); break; - case Routine : - if (!main.generics().list.isEmpty()) - { - FeErrors.mainFeatureMustNotHaveTypeArguments(main); - } - break; - default : FeErrors.mainFeatureMustNot(main, "be of kind " + main.kind() + "."); - } - } var result = new MIR(universe, main, mirMod); if (!Errors.any()) { diff --git a/src/dev/flang/fe/SourceModule.java b/src/dev/flang/fe/SourceModule.java index cc03544a57..0be623090a 100644 --- a/src/dev/flang/fe/SourceModule.java +++ b/src/dev/flang/fe/SourceModule.java @@ -63,8 +63,6 @@ import dev.flang.ast.State; import dev.flang.ast.Types; import dev.flang.ast.Visi; -import dev.flang.mir.MIR; -import dev.flang.mir.MirModule; import dev.flang.parser.Parser; @@ -81,7 +79,7 @@ * * @author Fridtjof Siebert (siebert@tokiwa.software) */ -public class SourceModule extends Module implements SrcModule, MirModule +public class SourceModule extends Module implements SrcModule { /*---------------------------- variables ----------------------------*/ @@ -274,22 +272,33 @@ void createASTandResolve() } - /** - * Create the module intermediate representation for this module. - */ - public MIR createMIR(String main) + public void checkMain() { - var d = main == null - ? _universe - : _universe.get(this, main); - - if (false) // NYI: Eventually, we might want to stop here in case of errors. This is disabled just to check the robustness of the next steps + if (_main != null) { - Errors.showAndExit(); + var main = this._universe.get(this, _main); + if (main != null && !Errors.any()) + { + if (main.valueArguments().size() != 0) + { + FeErrors.mainFeatureMustNotHaveArguments(main); + } + switch (main.kind()) + { + case Field : FeErrors.mainFeatureMustNotBeField (main); break; + case Abstract : FeErrors.mainFeatureMustNotBeAbstract (main); break; + case Intrinsic: FeErrors.mainFeatureMustNotBeIntrinsic(main); break; + case Choice : FeErrors.mainFeatureMustNotBeChoice (main); break; + case Routine : + if (!main.generics().list.isEmpty()) + { + FeErrors.mainFeatureMustNotHaveTypeArguments(main); + } + break; + default : FeErrors.mainFeatureMustNot(main, "be of kind " + main.kind() + "."); + } + } } - - _closed = true; - return createMIR(this, _universe, d); } diff --git a/src/dev/flang/fuir/analysis/dfa/Env.java b/src/dev/flang/fuir/analysis/dfa/Env.java index 8d82f2403c..0d08e25312 100644 --- a/src/dev/flang/fuir/analysis/dfa/Env.java +++ b/src/dev/flang/fuir/analysis/dfa/Env.java @@ -150,7 +150,7 @@ else if (outer.hasEffect(et)) _types [i] = insert ? et : ot[j]; _initialEffectValues[i] = insert ? ev : oi[j]; j = j + (insert ? 0 : 1); - left = insert && left; + left = !insert && left; } } _outer = outer; diff --git a/src/dev/flang/tools/CheckIntrinsics.java b/src/dev/flang/tools/CheckIntrinsics.java index c0d44aee4a..fdc7097884 100644 --- a/src/dev/flang/tools/CheckIntrinsics.java +++ b/src/dev/flang/tools/CheckIntrinsics.java @@ -56,7 +56,7 @@ static interface Mangle CheckIntrinsics(FrontEnd fe) { var all = new TreeSet(); - getAll(all, fe, fe._universe); + getAll(all, fe, fe.baseModule().libraryUniverse()); var i = dev.flang.be.interpreter.Intrinsics.supportedIntrinsics(); checkIntrinsics(all, true, i, "Interpreter backend", x->x); @@ -73,7 +73,7 @@ static interface Mangle void getAll(TreeSet all, FrontEnd fe, AbstractFeature outer) { - var s = fe._baseModule.declaredFeatures(outer); + var s = fe.baseModule().declaredFeatures(outer); for (var f : s.values()) { getAll(all, fe, f); diff --git a/src/dev/flang/tools/fzjava/FZJava.java b/src/dev/flang/tools/fzjava/FZJava.java index ece550b4be..2d5822a018 100644 --- a/src/dev/flang/tools/fzjava/FZJava.java +++ b/src/dev/flang/tools/fzjava/FZJava.java @@ -536,7 +536,7 @@ void processClass(Class c) */ void createOuter(String jfn) { - recurseDeclaredFeature(jfn.replace("/", "."), _fe._universe); + recurseDeclaredFeature(jfn.replace("/", "."), _fe.baseModule().libraryUniverse()); var pkg = jfn.substring(0, jfn.lastIndexOf("/")); if (pkg.indexOf("/") >= 0) diff --git a/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err b/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err index 33356493f2..2ae9114478 100644 --- a/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err +++ b/tests/compile_time_type_casts_negative2/compile_time_type_casts_negative2.fz.expected_err @@ -7,9 +7,9 @@ fuzion.runtime.fault.cause#1 fuzion.type.runtime.type.pre_fault.type.install_default.λ.call#1 fuzion.runtime.pre_fault.cause#1 fuzion.runtime.precondition_fault#1 -(compile_time_type_casts_negative2.use_x#3 compile_time_type_casts_negative2.a).pre do_b_thing -(compile_time_type_casts_negative2.use_x#3 compile_time_type_casts_negative2.a).precall do_b_thing -compile_time_type_casts_negative2.use_x#3 compile_time_type_casts_negative2.a +(compile_time_type_casts_negative2.use_x#4 compile_time_type_casts_negative2.a).pre do_b_thing +(compile_time_type_casts_negative2.use_x#4 compile_time_type_casts_negative2.a).precall do_b_thing +compile_time_type_casts_negative2.use_x#4 compile_time_type_casts_negative2.a compile_time_type_casts_negative2 *** fatal errors encountered, stopping. diff --git a/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err b/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err index 3da4e298ec..7e96fa8afb 100644 --- a/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err +++ b/tests/local_mutate_negative/test_local_mutate_neg.fz.expected_err @@ -9,7 +9,7 @@ effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum.sum#1 ----------^^^^^ effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum.sum#1' at --CURDIR--/test_local_mutate_neg.fz:114:5: sum l0 -----^^^ +----^^^^^^ effect environment '--empty--' for call to 'test_local_mutate_neg.test_sum' at --CURDIR--/test_local_mutate_neg.fz:116:3: test_sum --^^^^^^^^ diff --git a/tests/reg_issue2273/reg_issue2273.fz.expected_err b/tests/reg_issue2273/reg_issue2273.fz.expected_err index ae5a3bfada..ac77a1dc34 100644 --- a/tests/reg_issue2273/reg_issue2273.fz.expected_err +++ b/tests/reg_issue2273/reg_issue2273.fz.expected_err @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:106:5: error 1: Failed to verify that effect 'mutate' is ----^^^^^^ Callchain that lead to this point: -effect environment '--empty--' for call to '(mutate.type.array.type door).new#3 mutate' at --CURDIR--/reg_issue2273.fz:33:26: +effect environment '--empty--' for call to '(mutate.type.array.type door).new#3 mutate' at --CURDIR--/reg_issue2273.fz:33:6: d := (mutate.array door).new mutate 100 closed --------------------------^^^ +-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ effect environment '--empty--' for call to 'universe' effect environment '--empty--' at program entry diff --git a/tests/reg_issue2564/reg_issue2564.fz.expected_err b/tests/reg_issue2564/reg_issue2564.fz.expected_err index 9d9b5a8152..6bd56782dc 100644 --- a/tests/reg_issue2564/reg_issue2564.fz.expected_err +++ b/tests/reg_issue2564/reg_issue2564.fz.expected_err @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:112:5: error 1: Failed to verify that effect 'mutate' is ----^^^^^^ Callchain that lead to this point: -effect environment '--empty--' for call to '(mutate.type.array.type Any).new#1 mutate' at --CURDIR--/reg_issue2564.fz:26:32: +effect environment '--empty--' for call to '(mutate.type.array.type Any).new#1 mutate' at --CURDIR--/reg_issue2564.fz:26:8: o := (mutate.array Any).type.new mutate --------------------------------^^^ +-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ effect environment '--empty--' for call to 'reg_issue2564' effect environment '--empty--' at program entry diff --git a/tests/reg_issue3147/reg_issue3147.fz.expected_err b/tests/reg_issue3147/reg_issue3147.fz.expected_err index 740a27c458..115129d430 100644 --- a/tests/reg_issue3147/reg_issue3147.fz.expected_err +++ b/tests/reg_issue3147/reg_issue3147.fz.expected_err @@ -7,16 +7,16 @@ Feature 't.type' instantiated at : inherits or declares abstract feature 't.type.doit' declared at --CURDIR--/reg_issue3147.fz:25:8: type.doit unit => abstract -------^^^^ -which is called at --CURDIR--/reg_issue3147.fz:27:23: +which is called at --CURDIR--/reg_issue3147.fz:27:21: test(X type : t) => X.doit -----------------------^^^^ +--------------------^^^^^^ without providing an implementation Callchain that lead to this point: call 'test#1 t' at --CURDIR--/reg_issue3147.fz:29:1: test t -^^^^ +^^^^^^ call 'universe' program entry point diff --git a/tests/reg_issue3199/reg_issue3199.fz.expected_err b/tests/reg_issue3199/reg_issue3199.fz.expected_err index 1971e31c2f..bc3dd6d6f3 100644 --- a/tests/reg_issue3199/reg_issue3199.fz.expected_err +++ b/tests/reg_issue3199/reg_issue3199.fz.expected_err @@ -7,9 +7,9 @@ Feature 'reg_issue3199.y' instantiated at : inherits or declares abstract feature 'reg_issue3199.X.f' declared at --CURDIR--/reg_issue3199.fz:27:5: f i32 => abstract ----^ -which is called at --CURDIR--/reg_issue3199.fz:32:9: +which is called at --CURDIR--/reg_issue3199.fz:32:7: say x.f ---------^ +------^^^ without providing an implementation Callchain that lead to this point: diff --git a/tests/reg_issue3359/reg_issue3359.fz.expected_err b/tests/reg_issue3359/reg_issue3359.fz.expected_err index 09dd9e2485..d4d7146e6e 100644 --- a/tests/reg_issue3359/reg_issue3359.fz.expected_err +++ b/tests/reg_issue3359/reg_issue3359.fz.expected_err @@ -8,22 +8,22 @@ Feature 'reg_issue3359.i' instantiated at --CURDIR--/reg_issue3359.fz:103:5: inherits or declares abstract feature 'reg_issue3359.i.q' declared at --CURDIR--/reg_issue3359.fz:77:5: q unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:96:41: +which is called at --CURDIR--/reg_issue3359.fz:96:39: if envir.args.count = 0 then v.q -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5: r unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:97:41: +which is called at --CURDIR--/reg_issue3359.fz:97:39: else if envir.args.count = 1 then v.r -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: -call 'reg_issue3359.u#1 reg_issue3359.i' at --CURDIR--/reg_issue3359.fz:103:3: +call 'reg_issue3359.u#2 reg_issue3359.i' at --CURDIR--/reg_issue3359.fz:103:3: u i ---^ +--^^^ call 'reg_issue3359' program entry point @@ -37,22 +37,22 @@ Feature 'reg_issue3359.j' instantiated at --CURDIR--/reg_issue3359.fz:106:5: inherits or declares abstract feature 'reg_issue3359.i.q' declared at --CURDIR--/reg_issue3359.fz:77:5: q unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:96:41: +which is called at --CURDIR--/reg_issue3359.fz:96:39: if envir.args.count = 0 then v.q -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5: r unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:97:41: +which is called at --CURDIR--/reg_issue3359.fz:97:39: else if envir.args.count = 1 then v.r -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: -call 'reg_issue3359.u#1 reg_issue3359.j' at --CURDIR--/reg_issue3359.fz:106:3: +call 'reg_issue3359.u#2 reg_issue3359.j' at --CURDIR--/reg_issue3359.fz:106:3: u j ---^ +--^^^ call 'reg_issue3359' program entry point @@ -66,16 +66,16 @@ Feature 'reg_issue3359.k' instantiated at --CURDIR--/reg_issue3359.fz:109:5: inherits or declares abstract feature 'reg_issue3359.i.r' declared at --CURDIR--/reg_issue3359.fz:78:5: r unit => abstract ----^ -which is called at --CURDIR--/reg_issue3359.fz:97:41: +which is called at --CURDIR--/reg_issue3359.fz:97:39: else if envir.args.count = 1 then v.r -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: -call 'reg_issue3359.u#1 reg_issue3359.k' at --CURDIR--/reg_issue3359.fz:109:3: +call 'reg_issue3359.u#2 reg_issue3359.k' at --CURDIR--/reg_issue3359.fz:109:3: u k ---^ +--^^^ call 'reg_issue3359' program entry point @@ -88,22 +88,22 @@ Feature 'reg_issue3359.f.type' instantiated at : inherits or declares abstract feature 'reg_issue3359.f.type.n' declared at --CURDIR--/reg_issue3359.fz:35:10: type.n unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:54:41: +which is called at --CURDIR--/reg_issue3359.fz:54:39: if envir.args.count = 0 then T.n -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10: type.o unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:55:41: +which is called at --CURDIR--/reg_issue3359.fz:55:39: else if envir.args.count = 1 then T.o -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: call 'reg_issue3359.t#1 reg_issue3359.f' at --CURDIR--/reg_issue3359.fz:61:3: t f ---^ +--^^^ call 'reg_issue3359' program entry point @@ -116,22 +116,22 @@ Feature 'reg_issue3359.g.type' instantiated at : inherits or declares abstract feature 'reg_issue3359.f.type.n' declared at --CURDIR--/reg_issue3359.fz:35:10: type.n unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:54:41: +which is called at --CURDIR--/reg_issue3359.fz:54:39: if envir.args.count = 0 then T.n -----------------------------------------^ +--------------------------------------^^^ and abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10: type.o unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:55:41: +which is called at --CURDIR--/reg_issue3359.fz:55:39: else if envir.args.count = 1 then T.o -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: call 'reg_issue3359.t#1 reg_issue3359.g' at --CURDIR--/reg_issue3359.fz:64:3: t g ---^ +--^^^ call 'reg_issue3359' program entry point @@ -144,16 +144,16 @@ Feature 'reg_issue3359.h.type' instantiated at : inherits or declares abstract feature 'reg_issue3359.f.type.o' declared at --CURDIR--/reg_issue3359.fz:36:10: type.o unit => abstract ---------^ -which is called at --CURDIR--/reg_issue3359.fz:55:41: +which is called at --CURDIR--/reg_issue3359.fz:55:39: else if envir.args.count = 1 then T.o -----------------------------------------^ +--------------------------------------^^^ without providing an implementation Callchain that lead to this point: call 'reg_issue3359.t#1 reg_issue3359.h' at --CURDIR--/reg_issue3359.fz:67:3: t h ---^ +--^^^ call 'reg_issue3359' program entry point diff --git a/tests/reg_issue348/reg_issue348.fz.expected_err b/tests/reg_issue348/reg_issue348.fz.expected_err index 611111849a..680e265cfb 100644 --- a/tests/reg_issue348/reg_issue348.fz.expected_err +++ b/tests/reg_issue348/reg_issue348.fz.expected_err @@ -4,9 +4,9 @@ $MODULE/mutate/array.fz:106:5: error 1: Failed to verify that effect 'reg_issue3 ----^^^^^^ Callchain that lead to this point: -effect environment '--empty--' for call to '(mutate.type.array.type reg_issue348.a).new#3 reg_issue348.m' at --CURDIR--/reg_issue348.fz:33:32: +effect environment '--empty--' for call to '(mutate.type.array.type reg_issue348.a).new#3 reg_issue348.m' at --CURDIR--/reg_issue348.fz:33:10: arr := (mutate.array a).type.new m 10 a --------------------------------^^^ +---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ effect environment '--empty--' for call to 'reg_issue348' effect environment '--empty--' at program entry From 1a036daa4a55271b566e2cc07c3891b43db2f2a9 Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Fri, 13 Sep 2024 12:06:34 +0200 Subject: [PATCH 3/3] fe: fix module loading with correct universe and correct dependsOn --- src/dev/flang/fe/FrontEnd.java | 53 +++++++++++++++++++++++----- src/dev/flang/fe/LibraryFeature.java | 3 +- src/dev/flang/fe/LibraryModule.java | 16 +++++---- src/dev/flang/fe/Module.java | 2 -- src/dev/flang/tools/Fuzion.java | 2 +- src/dev/flang/tools/docs/Docs.java | 6 ++-- 6 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/dev/flang/fe/FrontEnd.java b/src/dev/flang/fe/FrontEnd.java index 64bf818d6f..07d8367db3 100644 --- a/src/dev/flang/fe/FrontEnd.java +++ b/src/dev/flang/fe/FrontEnd.java @@ -38,6 +38,7 @@ import java.util.Collection; import java.util.EnumSet; import java.util.TreeMap; +import java.util.function.Function; import dev.flang.mir.MIR; @@ -157,11 +158,10 @@ public FrontEnd(FrontEndOptions options) sourceDirs[i] = new SourceDir(sourcePaths[i]); } - loadModules(universe); + var dependsOn = loadModules(universe); if (options._loadSources) { - var dependsOn = _modules.values().toArray(LibraryModule[]::new); _sourceModule = new SourceModule(options, sourceDirs, dependsOn, universe); _sourceModule.createASTandResolve(); } @@ -172,16 +172,40 @@ public FrontEnd(FrontEndOptions options) } - private void loadModules(Universe universe) + /** + * Load modules using universe. + * + * @param universe the universe to use to load the modules + * + * @return dependsOn, usually base module and modules explicitly specified in -modules=... + */ + private LibraryModule[] loadModules(AbstractFeature universe) { if (_options._loadBaseLib) { module(FuzionConstants.BASE_MODULE_NAME, modulePath(FuzionConstants.BASE_MODULE_NAME), universe); } _options._modules.stream().forEach(mn -> loadModule(mn, universe)); + + // Visibility not propagated through modules: see #484 + return _modules + .entrySet() + .stream() + .filter(kv -> { + var moduleName = kv.getKey(); + return _options._loadBaseLib && moduleName.equals(FuzionConstants.BASE_MODULE_NAME) + || _options._modules.contains(moduleName); + }) + .map(x -> x.getValue()) + .toArray(LibraryModule[]::new); } + /** + * reset almost all data in the front end. + * + * NYI: CLEANUP: remove this code + */ private void reset() { _totalModuleData = 0; @@ -240,7 +264,7 @@ private LibraryModule module(String m, Path p, AbstractFeature universe) try (var ch = (FileChannel) Files.newByteChannel(p, EnumSet.of(StandardOpenOption.READ))) { var data = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size()); - result = libModule(data, universe); + result = libModule(data, x -> new LibraryModule[0], universe); if (!m.equals(result.name())) { Errors.error("Module name mismatch for module file '" + p + "' expected name '" + @@ -256,11 +280,10 @@ private LibraryModule module(String m, Path p, AbstractFeature universe) return result; } - /** * create a new LibraryModule from `data` */ - private LibraryModule libModule(ByteBuffer data, AbstractFeature universe) + private LibraryModule libModule(ByteBuffer data, Function loadDependsOn, AbstractFeature universe) { LibraryModule result; var base = _totalModuleData; @@ -268,6 +291,7 @@ private LibraryModule libModule(ByteBuffer data, AbstractFeature universe) result = new LibraryModule(GLOBAL_INDEX_OFFSET + base, this, data, + loadDependsOn, universe); return result; } @@ -304,6 +328,11 @@ LibraryModule loadModule(String m, AbstractFeature universe) /*----------------------------- methods -----------------------------*/ + /** + * create the module intermediate representation + * + * @return the MIR + */ public MIR createMIR() { var main = _sourceModule._main; @@ -312,8 +341,13 @@ public MIR createMIR() } - public SourceModule module() + /** + * @return The source module. + */ + public SourceModule sourceModule() { + if (CHECKS) check + (_sourceModule != null); return _sourceModule; } @@ -339,13 +373,16 @@ public LibraryModule mainModule() var data = _sourceModule.data("main"); reset(); - _mainModule = libModule(data, null /* use universe of module */); + _mainModule = libModule(data, af -> loadModules(af), null /* use universe of module */); var ignore = new Types.Resolved((target,fn) -> _mainModule.lookupFeature(target, fn, null), _mainModule.libraryUniverse()); } return _mainModule; } + /** + * @return The base module. + */ public LibraryModule baseModule() { return _modules.get("base"); diff --git a/src/dev/flang/fe/LibraryFeature.java b/src/dev/flang/fe/LibraryFeature.java index 4c863f19f5..dcf31a357f 100644 --- a/src/dev/flang/fe/LibraryFeature.java +++ b/src/dev/flang/fe/LibraryFeature.java @@ -52,6 +52,7 @@ import dev.flang.ast.FeatureVisitor; import dev.flang.ast.InlineArray; import dev.flang.ast.Tag; +import dev.flang.ast.Types; import dev.flang.ast.Universe; import dev.flang.ast.Visi; @@ -432,7 +433,7 @@ public AbstractType resultType() } else if (isChoice()) { - return _libModule.lookupFeature(_libModule.libraryUniverse(), FeatureName.get("void", 0), null).selfType(); + return Types.resolved.t_void; } else { diff --git a/src/dev/flang/fe/LibraryModule.java b/src/dev/flang/fe/LibraryModule.java index cdcac7f82b..913c653bbe 100644 --- a/src/dev/flang/fe/LibraryModule.java +++ b/src/dev/flang/fe/LibraryModule.java @@ -35,6 +35,8 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; +import java.util.function.Consumer; +import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Collectors; @@ -172,9 +174,9 @@ public class LibraryModule extends Module implements MirModule /** * Create LibraryModule for given options and sourceDirs. */ - LibraryModule(int globalBase, FrontEnd fe, ByteBuffer data, AbstractFeature universe) + LibraryModule(int globalBase, FrontEnd fe, ByteBuffer data, Function loadDependsOn, AbstractFeature universe) { - super(null /* will be set later, need to load first */); + super(null /* set later, we need correct universe first */); _globalBase = globalBase; _mir = null; @@ -189,9 +191,15 @@ public class LibraryModule extends Module implements MirModule _modules = new ModuleRef[mrc]; var p = moduleRefsPos(); int moduleOffset = _data.limit(); + this._universe = universe == null ? libraryUniverse() : universe; if (CHECKS) check (_universe.isUniverse()); + + _dependsOn = loadDependsOn.apply(universe()); + if (CHECKS) + check(_dependsOn != null); + for (int i = 0; i < mrc; i++) { var n = moduleRefName(p); @@ -207,10 +215,6 @@ public class LibraryModule extends Module implements MirModule moduleOffset = moduleOffset + mr.size(); p = moduleRefNextPos(p); } - _dependsOn = Arrays.stream(_modules) - .map(mr -> mr._module) - .collect(Collectors.toList()) - .toArray(new LibraryModule[_modules.length]); var dm = fe._options._dumpModules; if (DUMP || diff --git a/src/dev/flang/fe/Module.java b/src/dev/flang/fe/Module.java index d3b1070f71..93e53f1fe0 100644 --- a/src/dev/flang/fe/Module.java +++ b/src/dev/flang/fe/Module.java @@ -498,8 +498,6 @@ private SortedMap> declaredOrInheritedFeature */ SortedMap> declaredOrInheritedFeatures(AbstractFeature outer) { - if (CHECKS) check - (_dependsOn != null); return this.declaredOrInheritedFeatures(outer, _dependsOn); } diff --git a/src/dev/flang/tools/Fuzion.java b/src/dev/flang/tools/Fuzion.java index bcae0e6722..184fc19489 100644 --- a/src/dev/flang/tools/Fuzion.java +++ b/src/dev/flang/tools/Fuzion.java @@ -350,7 +350,7 @@ void processFrontEnd(Fuzion f, FrontEnd fe) { n = n.substring(0, n.length() - sfx.length()); } - var data = fe.module().data(n); + var data = fe.sourceModule().data(n); if (data != null) { try (var os = Files.newOutputStream(p)) diff --git a/src/dev/flang/tools/docs/Docs.java b/src/dev/flang/tools/docs/Docs.java index 5388891b7f..04d025d4c5 100644 --- a/src/dev/flang/tools/docs/Docs.java +++ b/src/dev/flang/tools/docs/Docs.java @@ -115,7 +115,7 @@ private void breadthFirstTraverse0(Consumer c, Queue declaredFeatures(AbstractFeature f) { - return fe.module() + return fe.sourceModule() .declaredFeatures(f) .values() .stream(); @@ -130,7 +130,7 @@ private Stream declaredFeatures(AbstractFeature f) private Stream allInnerAndInheritedFeatures(AbstractFeature f) { var result = new List(); - fe.module().forEachDeclaredOrInheritedFeature(f, af -> result.add(af)); + fe.sourceModule().forEachDeclaredOrInheritedFeature(f, af -> result.add(af)); return result .stream(); } @@ -310,7 +310,7 @@ private void run(DocsOptions config) }, universe); - var htmlTool = new Html(config, mapOfDeclaredFeatures, universe, fe.module()); + var htmlTool = new Html(config, mapOfDeclaredFeatures, universe, fe.sourceModule()); mapOfDeclaredFeatures .keySet()