Buggy code:
public abstract class AbstractModule extends SModuleBase implements EditableSModule , FileSystemListener { private static final Logger LOG = LogManager . getLogger ( AbstractModule . class ) ; public static final String MODULE_DIR = "module" ; public static final String CLASSES_GEN = "classes_gen" ; public static final String CLASSES = "classes" ; protected final IFile myDescriptorFile ; private SModuleReference myModuleReference ; private Set < ModelRoot > mySModelRoots = new LinkedHashSet < ModelRoot > ( ) ; private Set < ModuleFacetBase > myFacets = new LinkedHashSet < ModuleFacetBase > ( ) ; private AbstractModule . ModuleScope myScope = new AbstractModule . ModuleScope ( ) ; protected boolean myChanged = false ; protected AbstractModule ( ) { } protected AbstractModule ( @ Nullable IFile myDescriptorFile ) { } @ Override public SModuleId getModuleId ( ) { } @ Override public String getModuleName ( ) { } @ Override public Iterable < SDependency > getDeclaredDependencies ( ) { SRepository repository = getRepository ( ) ; if ( repository == null ) throw new IllegalStateException ( "No<seq2seq4repair_space>repository<seq2seq4repair_space>to<seq2seq4repair_space>resolve<seq2seq4repair_space>dependencies<seq2seq4repair_space>references" ) ; Iterable < Dependency > unresolvedDeps = getUnresolvedDependencies ( ) ; List < SDependency > resolvedDeps = new ArrayList < SDependency > ( ) ; for ( Dependency dep : unresolvedDeps ) { SModuleReference moduleRef = dep . getModuleRef ( ) ; <START_BUG> SModule target = moduleRef . resolve ( repository ) ; <END_BUG> if ( target != null ) { resolvedDeps . add ( new jetbrains . mps . module . SDependencyImpl ( target , dep . getScope ( ) , dep . isReexport ( ) ) ) ; } } return resolvedDeps ; } public Iterable < Dependency > getUnresolvedDependencies ( ) { } public Set < SLanguage > getAllUsedLanguages ( ) { } @ Override public Set < SLanguage > getUsedLanguages ( ) { } @ Override public SModel resolveInDependencies ( SModelId ref ) { } protected void setModuleReference ( @ NotNull SModuleReference reference ) { } @ Override @ NotNull public SModuleReference getModuleReference ( ) { } public ModuleDescriptor getModuleDescriptor ( ) { } public final void setModuleDescriptor ( ModuleDescriptor moduleDescriptor ) { } protected void doSetModuleDescriptor ( ModuleDescriptor moduleDescriptor ) { } @ Override public void setChanged ( ) { } @ Override public void save ( ) { } @ Nullable public Dependency addDependency ( @ NotNull SModuleReference moduleRef , boolean reexport ) { } public void removeDependency ( @ NotNull Dependency dependency ) { } public void addUsedLanguage ( SModuleReference langRef ) { } public void removeUsedLanguage ( SModuleReference langRef ) { } public void addUsedDevkit ( SModuleReference devkitRef ) { } public void removeUsedDevkit ( SModuleReference devkitRef ) { } @ Deprecated @ ToRemove ( version = 3.2 ) public final List < Dependency > getDependencies ( ) { } @ Deprecated public final Collection < SModuleReference > getUsedLanguagesReferences ( ) { } protected void updatePackagedDescriptor ( ) { } @ Nullable private String convertPath ( String originalPath , IFile bundleHome , IFile sourcesDescriptorFile , ModuleDescriptor descriptor ) { } @ Override public Iterable < ModelRoot > getModelRoots ( ) { } protected void reloadAfterDescriptorChange ( ) { } private void initFacetsAndModels ( ) { } protected void collectFacetTypes ( Set < String > types ) { } protected ModuleFacetBase setupFacet ( ModuleFacetBase facet , Memento memento ) { } protected void updateFacets ( ) { } public void onModuleLoad ( ) { } @ Override public boolean isReadOnly ( ) { } @ Override public boolean isPackaged ( ) { } public IFile getModuleSourceDir ( ) { } public IFile getDescriptorFile ( ) { } @ NotNull public SearchScope getScope ( ) { } @ Override public void attach ( @ NotNull SRepository repository ) { } @ Override public IFile getFileToListen ( ) { } @ Override public Iterable < FileSystemListener > getListenerDependencies ( ) { } @ Override public void update ( ProgressMonitor monitor , FileSystemEvent event ) { } @ Override public void dispose ( ) { } public List < String > getSourcePaths ( ) { } public void updateModelsSet ( ) { } protected Iterable < ModelRoot > loadRoots ( ) { } private void doUpdateModelsSet ( ) { } public static void handleReadProblem ( AbstractModule module , Exception e , boolean isInConflict ) { } public void updateSModelReferences ( ) { } public void updateModuleReferences ( ) { } protected void dependenciesChanged ( ) { } protected ModuleDescriptor loadDescriptor ( ) { } @ Override public boolean isChanged ( ) { } @ Nullable @ Override public < T extends SModuleFacet > T getFacet ( Class < T > clazz ) { } @ Override public Iterable < SModuleFacet > getFacets ( ) { } public class ModuleScope extends DefaultScope { protected ModuleScope ( ) { } public AbstractModule getModule ( ) { } @ Override protected Set < SModule > getInitialModules ( ) { } @ Override protected Set < Language > getInitialUsedLanguages ( ) { } public String toString ( ) { } } public IFile getOutputPath ( ) { } @ Deprecated public final String getGeneratorOutputPath ( ) { } @ Deprecated public final String getTestsGeneratorOutputPath ( ) { } public void validateLanguageVersions ( ) { } @ Override public int getUsedLanguageVersion ( SLanguage usedLanguage ) { } }

Fix:
SModule target = ModuleRepositoryFacade . getInstance ( ) . getModule ( moduleRef ) ;