org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument Java Examples

The following examples show how to use org.eclipse.xtext.xbase.typesystem.references.LightweightBoundTypeArgument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CollectionLiteralsTypeComputer.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean isExpectedType(LightweightTypeReference expectation, Class<?> clazz) {
	if (expectation != null) {
		if (expectation.isResolved() && isSubtypeButNotSynonym(expectation, clazz)) {
			return true;
		}
		if (expectation instanceof UnboundTypeReference) {
			if (expectation.getOwner().newParameterizedTypeReference(((UnboundTypeReference) expectation).getTypeParameter()).isSubtypeOf(clazz)) {
				return true;
			}
			List<LightweightBoundTypeArgument> hints = ((UnboundTypeReference) expectation).getAllHints();
			for(LightweightBoundTypeArgument hint: hints) {
				LightweightTypeReference hintReference = hint.getTypeReference();
				if (hintReference != null && isSubtypeButNotSynonym(hintReference, clazz)) {
					return true;
				}
			}
		} else if (expectation instanceof ParameterizedTypeReference) {
			return isSubtypeButNotSynonym(expectation, clazz);
		}
	}
	return false;
}
 
Example #2
Source File: UnboundTypeParameterAwareTypeArgumentCollector.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void doVisitUnboundTypeReference(UnboundTypeReference reference, UnboundTypeReference declaration) {
	if (declaration.internalIsResolved() || getOwner().isResolved(declaration.getHandle())) {
		declaration.tryResolve();
		outerVisit(declaration, reference, declaration, getExpectedVariance(), getActualVariance());
	} else {
		if (getParametersToProcess().contains(declaration.getTypeParameter()) && VarianceInfo.OUT == getActualVariance() && VarianceInfo.OUT == getExpectedVariance()) {
			if (getDefaultSource() == BoundTypeArgumentSource.EXPECTATION) {
				List<LightweightBoundTypeArgument> hints = reference.getAllHints();
				for(int i = 0; i < hints.size(); i++) {
					if (hints.get(i).getSource() == BoundTypeArgumentSource.INFERRED) {
						return;
					}
				}
			}
		}
		acceptHint(declaration, reference);
	}
}
 
Example #3
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> assertOrigins(final Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> mapping, final String typeParamName, final int count) {
  final Set<JvmTypeParameter> allKeys = mapping.keySet();
  for (final JvmTypeParameter key : allKeys) {
    String _simpleName = key.getSimpleName();
    boolean _equals = Objects.equal(_simpleName, typeParamName);
    if (_equals) {
      final List<LightweightBoundTypeArgument> mappingData = mapping.get(key);
      final Function1<LightweightBoundTypeArgument, Object> _function = (LightweightBoundTypeArgument it) -> {
        return it.getOrigin();
      };
      Assert.assertEquals(count, IterableExtensions.<Object>toSet(ListExtensions.<LightweightBoundTypeArgument, Object>map(mappingData, _function)).size());
      return mapping;
    }
  }
  return mapping;
}
 
Example #4
Source File: ResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public List<LightweightBoundTypeArgument> getAllHints(Object handle) {
	List<LightweightBoundTypeArgument> actualHints = getHints(handle);
	int i = 0;
	while(i < actualHints.size()) {
		LightweightBoundTypeArgument hint = actualHints.get(i);
		if (hint.getTypeReference() instanceof UnboundTypeReference) {
			break;
		}
		i++;
	}
	if (i >= actualHints.size())
		return actualHints;
	List<LightweightBoundTypeArgument> transitivity = Lists.newArrayList();
	Set<Object> seenHandles = Sets.newHashSet(handle); 
	transitivity.addAll(actualHints.subList(0, i));
	List<LightweightBoundTypeArgument> allRemaining = actualHints.subList(i, actualHints.size());
	addNonRecursiveHints(allRemaining, seenHandles, transitivity);
	return transitivity;
}
 
Example #5
Source File: ClosureTypeComputerUnitTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testHintsAfterPrepareComputation_03() throws Exception {
	JvmType iterableType = getTypeForName(Iterable.class, state);
	JvmType appendableType = getTypeForName(Appendable.class, state);
	JvmType charSequenceType = getTypeForName(CharSequence.class, state);
	ParameterizedTypeReference iterableTypeReference = state.getReferenceOwner().newParameterizedTypeReference(iterableType);
	WildcardTypeReference typeArgument = state.getReferenceOwner().newWildcardTypeReference();
	typeArgument.addUpperBound(state.getReferenceOwner().newParameterizedTypeReference(appendableType));
	typeArgument.addUpperBound(state.getReferenceOwner().newParameterizedTypeReference(charSequenceType));
	iterableTypeReference.addTypeArgument(typeArgument);
	
	TypeExpectation expectation = new TypeExpectation(iterableTypeReference, state, false);
	ClosureTypeComputer computer = new ClosureTypeComputer(closure("[|]", getContextResourceSet()), expectation, state);
	computer.selectStrategy();
	FunctionTypeReference closureType = computer.getExpectedClosureType();
	assertEquals("java.lang.Iterable.iterator()", computer.getOperation().getIdentifier());
	assertEquals("Iterable<Unbound[T]>", getEquivalentSimpleName(closureType));
	assertEquals("()=>Iterator<Unbound[T]>", closureType.getSimpleName());
	
	UnboundTypeReference closureTypeArgument = (UnboundTypeReference) closureType.getTypeArguments().get(0);
	List<LightweightBoundTypeArgument> hints = state.getResolvedTypes().getHints(closureTypeArgument.getHandle());
	assertEquals(hints.toString(), 2, hints.size());
}
 
Example #6
Source File: RawTypeConformanceComputer.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
private boolean isConstrainedRecursiveHintCheck(List<LightweightBoundTypeArgument> leftHints, LightweightTypeReference right) {
	boolean hasConstraints = false;
	for(LightweightBoundTypeArgument leftHint: leftHints) {
		if (leftHint.getSource() == BoundTypeArgumentSource.CONSTRAINT) {
			hasConstraints = true;
		}
		if (leftHint.getSource() == BoundTypeArgumentSource.INFERRED_LATER && leftHint.getActualVariance() == VarianceInfo.INVARIANT) {
			if (!hasConstraints) {
				return false;
			}
			LightweightTypeReference leftHintReference = leftHint.getTypeReference();
			if (leftHintReference.getUniqueIdentifier().equals(right.getUniqueIdentifier())) {
				return true;
			}
		}
	}
	return false;
}
 
Example #7
Source File: DeferredTypeParameterHintCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNestedUnboundExpectation_02() {
  List<LightweightBoundTypeArgument> _hasHintsFor = this.hasHintsFor(this.in("T", "Iterable<? extends T>", "java.util.List<String>"), "T");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.like(_hasHintsFor, _mappedTo_1);
}
 
Example #8
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBestEffortMapping_01() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.List<T>", "java.util.Set<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #9
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testInheritanceMapping_01() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("E", "Iterable<E>", "java.util.ArrayList<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "E", _mappedTo_1);
}
 
Example #10
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCircularTypeParams_09() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T extends org.eclipse.xtend.core.tests.typesystem.CharIterable<? extends T>", "CharSequence", "String");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("CharIterable<? extends CharSequence>", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #11
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnambiguousMapping_03() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("K, V", "java.util.Map<K, V>", "java.util.Map<String, Integer>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _assertMapping = this.assertMapping(_mappedBy, "K", _mappedTo_1);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("Integer", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.assertMapping(_assertMapping, "V", _mappedTo_3);
}
 
Example #12
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnambiguousMapping_02() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.Map<T, T>", "java.util.Map<String, String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1, _mappedTo_3);
}
 
Example #13
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnambiguousMapping_01() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.List<T>", "java.util.List<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #14
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnambiguousMapping_05() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T, T2", "T", "CharSequence", "T2", "CharSequence");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("CharSequence", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _assertMapping = this.assertMapping(_mappedBy, "T", _mappedTo_1);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("CharSequence", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.OUT);
  this.assertMapping(_assertMapping, "T2", _mappedTo_3);
}
 
Example #15
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDependentTypeParams_01() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T extends CharSequence, T2 extends T", "java.util.Map<T, T2>", "java.util.Map<String, String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _assertMapping = this.assertMapping(_mappedBy, "T", _mappedTo_1);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.assertMapping(_assertMapping, "T2", _mappedTo_3);
}
 
Example #16
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCircularTypeParams_11() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T extends (Object)=>T", "T", "Object");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("Object", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #17
Source File: DeferredTypeParameterHintCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUsedTwice() {
  List<LightweightBoundTypeArgument> _hasHintsFor = this.hasHintsFor(this.in("T", "java.util.Map<T, T>", "com.google.common.collect.BiMap<CharSequence, Integer>"), "T");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("CharSequence", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("Integer", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.like(_hasHintsFor, _mappedTo_1, _mappedTo_3);
}
 
Example #18
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBestEffortMapping_03() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.ArrayList<T>", "Iterable<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #19
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBestEffortMapping_02() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.ArrayList<T>", "java.util.HashSet<String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #20
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUpperBound_02() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "Iterable<? extends T>", "Iterable<? extends String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #21
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCircularTypeParams_13() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T extends T2, T2 extends T", "T2", "String");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _assertMapping = this.assertMapping(_mappedBy, "T", _mappedTo_1);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.OUT);
  this.assertMapping(_assertMapping, "T2", _mappedTo_3);
}
 
Example #22
Source File: DeferredTypeParameterHintCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testDirectUnboundExpectation() {
  List<LightweightBoundTypeArgument> _hasHintsFor = this.hasHintsFor(this.in("T", "T", "String"), "T");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  this.like(_hasHintsFor, _mappedTo_1);
}
 
Example #23
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testLowerBound_09() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T extends T2, T2", "Iterable<? super T2>", "Iterable<? extends String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.IN);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.OUT);
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _assertMapping = this.assertMapping(_mappedBy, "T", _mappedTo_1);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("String", VarianceInfo.IN);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.OUT);
  this.assertMapping(_assertMapping, "T2", _mappedTo_3);
}
 
Example #24
Source File: TimedStackedResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<LightweightBoundTypeArgument> getAllHints(Object handle) {
	List<LightweightBoundTypeArgument> result = null;
	try {
		times.getHintsTask.start();
		result = super.getAllHints(handle);
	} finally {
		times.getHintsTask.stop();
	}
	return result;
}
 
Example #25
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testLowerBound_07() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "Iterable<Iterable<T>>", "java.util.LinkedList<Iterable<? super String>>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.IN);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #26
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUpperBound_11() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.Map<? extends T, ? extends T>", "java.util.Map<String, Integer>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("Integer", VarianceInfo.OUT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.assertOrigins(this.assertMapping(_mappedBy, "T", _mappedTo_1, _mappedTo_3), "T", 2);
}
 
Example #27
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testLowerBound_06() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "Iterable<T>", "Iterable<? super String>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.IN);
  this.assertMapping(_mappedBy, "T", _mappedTo_1);
}
 
Example #28
Source File: ValidatingStackedResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void acceptHint(Object handle, LightweightBoundTypeArgument boundTypeArgument) {
	if (boundTypeArgument.getTypeReference() != null && !boundTypeArgument.getTypeReference().isOwnedBy(getReferenceOwner())) {
		throw new IllegalArgumentException("reference is not owned by this resolved types");
	}
	super.acceptHint(handle, boundTypeArgument);
}
 
Example #29
Source File: ActualTypeArgumentCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBestEffortMapping_04() {
  Map<JvmTypeParameter, List<LightweightBoundTypeArgument>> _mappedBy = this.mappedBy("T", "java.util.HashMap<java.util.ArrayList<T>, java.util.ArrayList<T>>", "java.util.Map<Iterable<String>, java.util.HashSet<Integer>>");
  Pair<String, VarianceInfo> _mappedTo = Pair.<String, VarianceInfo>of("String", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_1 = this.operator_mappedTo(_mappedTo, VarianceInfo.INVARIANT);
  Pair<String, VarianceInfo> _mappedTo_2 = Pair.<String, VarianceInfo>of("Integer", VarianceInfo.INVARIANT);
  Triple<String, VarianceInfo, VarianceInfo> _mappedTo_3 = this.operator_mappedTo(_mappedTo_2, VarianceInfo.INVARIANT);
  this.assertMapping(_mappedBy, "T", _mappedTo_1, _mappedTo_3);
}
 
Example #30
Source File: ValidatingExpressionAwareResolvedTypes.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected List<LightweightBoundTypeArgument> getHints(Object handle) {
	List<LightweightBoundTypeArgument> result = super.getHints(handle);
	for (LightweightBoundTypeArgument it : result) {
		if (it.getTypeReference() != null && !it.getTypeReference().isOwnedBy(getReferenceOwner())) {
			throw new IllegalArgumentException("reference is not owned by this resolved types");
		}
	}
	return result;
}