@@ -62,6 +62,12 @@ class PolymodInterpEx extends Interp
6262 var clsRef = PolymodStaticClassReference .tryBuild (cl );
6363 if (clsRef != null ) return clsRef .instantiate (args );
6464
65+ if (getClassDecl ().imports != null && getClassDecl ().imports .exists (cl ))
66+ {
67+ var clsRef = PolymodStaticClassReference .tryBuild (getClassDecl ().imports .get (cl ).fullPath );
68+ if (clsRef != null ) return clsRef .instantiate (args );
69+ }
70+
6571 if (_proxy != null )
6672 {
6773 @:privateAccess
@@ -194,6 +200,26 @@ class PolymodInterpEx extends Interp
194200 return _scriptClassDescriptors .get (name );
195201 }
196202
203+ public static function validateImports ()
204+ {
205+ for (cls in _scriptClassDescriptors )
206+ {
207+ var clsPath = cls .pkg != null ? (cls .pkg .join (" ." ) + " ." ) : " " ;
208+ clsPath + = cls .name ;
209+
210+ for (key => imp in cls .importsToValidate )
211+ {
212+ if (_scriptClassDescriptors .exists (imp .fullPath ))
213+ {
214+ cls .imports .set (key , imp );
215+ continue ;
216+ }
217+
218+ Polymod .error (SCRIPT_CLASS_MODULE_NOT_FOUND , ' Could not import class ${imp .fullPath }' , clsPath );
219+ }
220+ }
221+ }
222+
197223 override function setVar (id : String , v : Dynamic )
198224 {
199225 if (_proxy != null && _proxy .superClass != null )
@@ -1255,6 +1281,7 @@ class PolymodInterpEx extends Interp
12551281 {
12561282 var pkg : Array <String > = null ;
12571283 var imports : Map <String , PolymodClassImport > = [];
1284+ var importsToValidate : Map <String , PolymodClassImport > = [];
12581285
12591286 for (importPath in PolymodScriptClass .defaultImports .keys ())
12601287 {
@@ -1316,7 +1343,8 @@ class PolymodInterpEx extends Interp
13161343
13171344 // If the class is still not found, skip this import entirely.
13181345 if (resultCls == null && resultEnm == null ) {
1319- Polymod .error (SCRIPT_CLASS_MODULE_NOT_FOUND , ' Could not import class ${importedClass .fullPath }' , origin );
1346+ // Polymod.error(SCRIPT_CLASS_MODULE_NOT_FOUND, 'Could not import class ${importedClass.fullPath}', origin);
1347+ importsToValidate .set (importedClass .name , importedClass );
13201348 continue ;
13211349 } else if (resultCls != null ) {
13221350 importedClass .cls = resultCls ;
@@ -1372,6 +1400,7 @@ class PolymodInterpEx extends Interp
13721400
13731401 var classDecl : PolymodClassDeclEx = {
13741402 imports : imports ,
1403+ importsToValidate : importsToValidate ,
13751404 pkg : pkg ,
13761405 name : c .name ,
13771406 params : c .params ,
0 commit comments