Skip to content

Commit

Permalink
add temporary work-around for GH-2235
Browse files Browse the repository at this point in the history
  • Loading branch information
mor-n4 committed Oct 20, 2021
1 parent bdbd9ea commit 8401ffd
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import java.util.Map.Entry;
import java.util.Set;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.n4js.resource.N4JSResource;
import org.eclipse.n4js.ts.types.TClass;
import org.eclipse.n4js.ts.types.TClassifier;
import org.eclipse.n4js.ts.types.TMember;
Expand Down Expand Up @@ -49,6 +52,7 @@ public MemberCube(TClassifier tClassifier, MemberCollector memberCollector) {

private void addMembers(int source, List<TMember> members) {
for (TMember member : members) {
ensureResolution(member);
NameStaticPair nsp = NameStaticPair.of(member);
MemberMatrix memberMatrix = memberMatrixesByName.get(nsp);
if (memberMatrix == null) {
Expand All @@ -59,6 +63,24 @@ private void addMembers(int source, List<TMember> members) {
}
}

/**
* TEMPORARY WORK-AROUND
*
* This is required to avoid exceptions when compiling n4js-libs.
*
* TODO GH-2235 find a better place to ensure resolution of polyfilled members
*/
private void ensureResolution(EObject obj) {
// ensure we do not use types from resources that are only partially resolved
Resource polyfillResource = obj.eResource();
if (polyfillResource instanceof N4JSResource) {
// Note: the following call will be a no-op if
// 1) the resource was already post-processed, or
// 2) the resource was loaded from the index.
((N4JSResource) polyfillResource).performPostProcessing();
}
}

/**
* @see java.util.Map#entrySet()
*/
Expand Down

0 comments on commit 8401ffd

Please sign in to comment.